diff options
| author | Mark Rowe <mark@vector35.com> | 2026-05-11 18:49:26 -0700 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2026-05-19 10:36:46 -0700 |
| commit | fd40266f767e51e649fb48376e25f47a60d79765 (patch) | |
| tree | db351a36617200d4ad659bb3c1aa921b8d08f204 /typecontainer.cpp | |
| parent | 297a98bff289ecde90d808f6538c2c5edf804af6 (diff) | |
Fix incorrect reference counting in C++ API
Diffstat (limited to 'typecontainer.cpp')
| -rw-r--r-- | typecontainer.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/typecontainer.cpp b/typecontainer.cpp index 3ecf6aa5..cbff21ee 100644 --- a/typecontainer.cpp +++ b/typecontainer.cpp @@ -80,6 +80,10 @@ TypeContainer::TypeContainer(const TypeContainer& other) TypeContainer& TypeContainer::operator=(const TypeContainer& other) { + if (this == &other) + return *this; + if (m_object) + BNFreeTypeContainer(m_object); m_object = BNDuplicateTypeContainer(other.m_object); return *this; } @@ -87,7 +91,11 @@ TypeContainer& TypeContainer::operator=(const TypeContainer& other) TypeContainer& TypeContainer::operator=(TypeContainer&& other) { - m_object = std::move(other.m_object); + if (this == &other) + return *this; + if (m_object) + BNFreeTypeContainer(m_object); + m_object = other.m_object; other.m_object = nullptr; return *this; } @@ -370,6 +378,7 @@ bool TypeContainer::ParseTypeString( if (!success) { + BNFreeQualifiedNameAndType(&apiResult); return false; } |
