diff options
| author | Peter LaFosse <peter@vector35.com> | 2025-04-14 08:33:03 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2025-04-29 09:16:13 -0400 |
| commit | 6697a9d2ce4bf7d544f98dafea7edfaecd7b6731 (patch) | |
| tree | 722cbb75a8331131caa1e57588815a3121f4bbc5 | |
| parent | d1722c0b34f313590f1f5a1274985433a58a7a5f (diff) | |
Fix memory leaks in Sections, Segments, Settings, ExternalLibrary, and BackgroundTask
| -rw-r--r-- | binaryview.cpp | 8 | ||||
| -rw-r--r-- | externallibrary.cpp | 2 | ||||
| -rw-r--r-- | python/binaryview.py | 8 | ||||
| -rw-r--r-- | settings.cpp | 2 |
4 files changed, 8 insertions, 12 deletions
diff --git a/binaryview.cpp b/binaryview.cpp index 9a223932..242b2a01 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -3835,7 +3835,7 @@ Ref<BackgroundTask> BinaryView::GetBackgroundAnalysisTask() if (!task) return nullptr; - return new BackgroundTask(BNNewBackgroundTaskReference(task)); + return new BackgroundTask(task); } @@ -4954,7 +4954,7 @@ Ref<Segment> BinaryView::GetSegmentAt(uint64_t addr) if (!segment) return nullptr; - return new Segment(BNNewSegmentReference(segment)); + return new Segment(segment); } @@ -5043,7 +5043,7 @@ Ref<Section> BinaryView::GetSectionByName(const string& name) { BNSection* section = BNGetSectionByName(m_object, name.c_str()); if (section) - return new Section(BNNewSectionReference(section)); + return new Section(section); return nullptr; } @@ -5386,7 +5386,7 @@ Ref<ExternalLibrary> BinaryView::AddExternalLibrary(const std::string& name, Ref BNExternalLibrary* lib = BNBinaryViewAddExternalLibrary(m_object, name.c_str(), backingFile ? backingFile->m_object : nullptr, isAuto); if (!lib) return nullptr; - return new ExternalLibrary(BNNewExternalLibraryReference(lib)); + return new ExternalLibrary(lib); } diff --git a/externallibrary.cpp b/externallibrary.cpp index 42e759fe..0ae2a89a 100644 --- a/externallibrary.cpp +++ b/externallibrary.cpp @@ -92,7 +92,7 @@ Ref<ExternalLibrary> ExternalLocation::GetExternalLibrary() BNExternalLibrary* lib = BNExternalLocationGetExternalLibrary(m_object); if (!lib) return nullptr; - return new ExternalLibrary(BNNewExternalLibraryReference(lib)); + return new ExternalLibrary(lib); } diff --git a/python/binaryview.py b/python/binaryview.py index 989c1f20..092f9bef 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -9545,9 +9545,7 @@ to a the type "tagRECT" found in the typelibrary "winX64common" seg = core.BNGetSegmentAt(self.handle, addr) if not seg: return None - segment_handle = core.BNNewSegmentReference(seg) - assert segment_handle is not None, "core.BNNewSegmentReference returned None" - return Segment(segment_handle) + return Segment(seg) def get_address_for_data_offset(self, offset: int) -> Optional[int]: """ @@ -9639,9 +9637,7 @@ to a the type "tagRECT" found in the typelibrary "winX64common" section = core.BNGetSectionByName(self.handle, name) if section is None: return None - section_handle = core.BNNewSectionReference(section) - assert section_handle is not None, "core.BNNewSectionReference returned None" - result = Section(section_handle) + result = Section(section) return result def get_unique_section_names(self, name_list: List[str]) -> List[str]: diff --git a/settings.cpp b/settings.cpp index 4d3f5acd..ba8d65f6 100644 --- a/settings.cpp +++ b/settings.cpp @@ -7,7 +7,7 @@ using namespace std; Settings::Settings(BNSettings* settings) { - m_object = BNNewSettingsReference(settings); + m_object = settings; } |
