From fd40266f767e51e649fb48376e25f47a60d79765 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Mon, 11 May 2026 18:49:26 -0700 Subject: Fix incorrect reference counting in C++ API --- typecontainer.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'typecontainer.cpp') 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; } -- cgit v1.3.1