From f9a9abdff9cc539f5a92c56f8942946a8ac718be Mon Sep 17 00:00:00 2001 From: Xusheng Date: Mon, 11 Sep 2023 17:04:20 +0800 Subject: Fix memory leak in functions calling BNCreateUserFunction --- binaryview.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index 6120e10f..db1974da 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -1795,9 +1795,12 @@ void BinaryView::RemoveAnalysisFunction(Function* func, bool updateRefs) } -void BinaryView::CreateUserFunction(Platform* platform, uint64_t start) +Ref BinaryView::CreateUserFunction(Platform* platform, uint64_t start) { - BNCreateUserFunction(m_object, platform->GetObject(), start); + BNFunction* func = BNCreateUserFunction(m_object, platform->GetObject(), start); + if (!func) + return nullptr; + return new Function(func); } -- cgit v1.3.1