summaryrefslogtreecommitdiff
path: root/debuginfo.cpp
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2023-11-14 18:35:38 -0500
committerGlenn Smith <glenn@vector35.com>2023-11-14 18:35:38 -0500
commit4025361513068463390900635313910200542556 (patch)
tree2dbfc8ef20c3eae8d849a02d833917dc24b28d28 /debuginfo.cpp
parent814d840c8d12dfcfb60a5bf172ea494825fd30c1 (diff)
Fix a number of leaks and bad uses of free in the api
See https://github.com/Vector35/binaryninja-api/issues/4751
Diffstat (limited to 'debuginfo.cpp')
-rw-r--r--debuginfo.cpp22
1 files changed, 11 insertions, 11 deletions
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> 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;
}