From 4025361513068463390900635313910200542556 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 14 Nov 2023 18:35:38 -0500 Subject: Fix a number of leaks and bad uses of free in the api See https://github.com/Vector35/binaryninja-api/issues/4751 --- debuginfo.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'debuginfo.cpp') diff --git a/debuginfo.cpp b/debuginfo.cpp index 5fef18d2..33cf67a8 100644 --- a/debuginfo.cpp +++ b/debuginfo.cpp @@ -276,20 +276,20 @@ bool DebugInfo::AddType(const string& name, Ref type) bool DebugInfo::AddFunction(const DebugFunctionInfo& function) { - BNDebugFunctionInfo* input = new BNDebugFunctionInfo(); + BNDebugFunctionInfo input; - input->shortName = function.shortName.size() ? BNAllocString(function.shortName.c_str()) : nullptr; - input->fullName = function.fullName.size() ? BNAllocString(function.fullName.c_str()) : nullptr; - input->rawName = function.rawName.size() ? BNAllocString(function.rawName.c_str()) : nullptr; - input->address = function.address; - input->type = function.type ? function.type->GetObject() : nullptr; - input->platform = function.platform ? function.platform->GetObject() : nullptr; + input.shortName = function.shortName.size() ? BNAllocString(function.shortName.c_str()) : nullptr; + input.fullName = function.fullName.size() ? BNAllocString(function.fullName.c_str()) : nullptr; + input.rawName = function.rawName.size() ? BNAllocString(function.rawName.c_str()) : nullptr; + input.address = function.address; + input.type = function.type ? function.type->GetObject() : nullptr; + input.platform = function.platform ? function.platform->GetObject() : nullptr; - bool result = BNAddDebugFunction(m_object, input); + bool result = BNAddDebugFunction(m_object, &input); - BNFreeString(input->shortName); - BNFreeString(input->fullName); - BNFreeString(input->rawName); + BNFreeString(input.shortName); + BNFreeString(input.fullName); + BNFreeString(input.rawName); return result; } -- cgit v1.3.1