summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2025-07-30 13:00:12 -0700
committerMark Rowe <mark@vector35.com>2025-08-05 11:53:14 -0700
commit073e04dcbbb90fdff8bebfbbd3a68bdd9d285954 (patch)
tree45bb8f14eff65e6719e133ee771d9d69a2eb1a33
parent8becb1ba6fcf327f38d8d5925605bf8217f40a32 (diff)
Avoid leaking Relocation instances
`BNRelocationHandlerDefaultApplyRelocation` / `BNRelocationHandlerApplyRelocation` / `BNRelocationHandlerGetOperandForExternalRelocation` do not take ownership of the reference that is passed to them. Instead they take their own reference to the object. As a result, `Relocation` objects passed into `RelocationHandler::ApplyRelocation` / `CoreRelocationHandler::ApplyRelocation` / `CoreRelocationHandler::GetOperandForExternalRelocation` were being leaked.
-rw-r--r--relocationhandler.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/relocationhandler.cpp b/relocationhandler.cpp
index cb91b9b1..ed0b609e 100644
--- a/relocationhandler.cpp
+++ b/relocationhandler.cpp
@@ -102,7 +102,7 @@ bool RelocationHandler::ApplyRelocation(
Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len)
{
return BNRelocationHandlerDefaultApplyRelocation(
- m_object, view->GetObject(), arch->GetObject(), BNNewRelocationReference(reloc->GetObject()), dest, len);
+ m_object, view->GetObject(), arch->GetObject(), reloc->GetObject(), dest, len);
}
@@ -125,7 +125,7 @@ bool CoreRelocationHandler::ApplyRelocation(
Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len)
{
return BNRelocationHandlerApplyRelocation(
- m_object, view->GetObject(), arch->GetObject(), BNNewRelocationReference(reloc->GetObject()), dest, len);
+ m_object, view->GetObject(), arch->GetObject(), reloc->GetObject(), dest, len);
}
@@ -148,5 +148,5 @@ size_t CoreRelocationHandler::GetOperandForExternalRelocation(
const uint8_t* data, uint64_t addr, size_t length, Ref<LowLevelILFunction> il, Ref<Relocation> relocation)
{
return BNRelocationHandlerGetOperandForExternalRelocation(
- m_object, data, addr, length, il->GetObject(), BNNewRelocationReference(relocation->GetObject()));
+ m_object, data, addr, length, il->GetObject(), relocation->GetObject());
}