summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2025-04-11 14:45:00 -0400
committerPeter LaFosse <peter@vector35.com>2025-04-29 09:16:13 -0400
commit0338bbd5e830d07e0e07803ee77107498976dfd1 (patch)
tree929766a365baea776a4b0c1b6e9d801714483447
parente3bbd4fb8d3eaff44a16f19e1840e2ecd20387de (diff)
Fix memory leaks in Component::GetGuid/GetName/GetDisplayName
-rw-r--r--component.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/component.cpp b/component.cpp
index 03be498a..30431e90 100644
--- a/component.cpp
+++ b/component.cpp
@@ -25,13 +25,19 @@ Component::Component(BNComponent* component)
std::string Component::GetDisplayName()
{
- return BNComponentGetDisplayName(m_object);
+ char* result = BNComponentGetDisplayName(m_object);
+ string stringResult = result;
+ BNFreeString(result);
+ return stringResult;
}
std::string Component::GetName()
{
- return BNComponentGetOriginalName(m_object);
+ char* result = BNComponentGetOriginalName(m_object);
+ string stringResult = result;
+ BNFreeString(result);
+ return stringResult;
}
@@ -55,7 +61,10 @@ Ref<Component> Component::GetParent()
std::string Component::GetGuid()
{
- return string(BNComponentGetGuid(m_object));
+ char* result = BNComponentGetGuid(m_object);
+ string stringResult = result;
+ BNFreeString(result);
+ return stringResult;
}