From 0c34857925e6b0c220871f921f5cf4d59bbdb403 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Fri, 13 Jun 2025 02:36:35 -0400 Subject: Fix misc memory leaks in C++ API --- binaryview.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index 242b2a01..310396c0 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -939,7 +939,10 @@ void TagType::SetName(const std::string& name) std::string TagType::GetIcon() const { - return BNTagTypeGetIcon(m_object); + char* str = BNTagTypeGetIcon(m_object); + string result = str; + BNFreeString(str); + return result; } @@ -1002,7 +1005,10 @@ Ref Tag::GetType() const std::string Tag::GetData() const { - return BNTagGetData(m_object); + char* str = BNTagGetData(m_object); + string result = str; + BNFreeString(str); + return result; } @@ -1278,13 +1284,19 @@ uint64_t Section::GetEntrySize() const std::string Section::GetLinkedSection() const { - return BNSectionGetLinkedSection(m_object); + char* str = BNSectionGetLinkedSection(m_object); + string result = str; + BNFreeString(str); + return result; } std::string Section::GetInfoSection() const { - return BNSectionGetInfoSection(m_object); + char* str = BNSectionGetInfoSection(m_object); + string result = str; + BNFreeString(str); + return result; } -- cgit v1.3.1