Skip to content

Commit 073e04d

Browse files
committed
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.
1 parent 8becb1b commit 073e04d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

relocationhandler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool RelocationHandler::ApplyRelocation(
102102
Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len)
103103
{
104104
return BNRelocationHandlerDefaultApplyRelocation(
105-
m_object, view->GetObject(), arch->GetObject(), BNNewRelocationReference(reloc->GetObject()), dest, len);
105+
m_object, view->GetObject(), arch->GetObject(), reloc->GetObject(), dest, len);
106106
}
107107

108108

@@ -125,7 +125,7 @@ bool CoreRelocationHandler::ApplyRelocation(
125125
Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len)
126126
{
127127
return BNRelocationHandlerApplyRelocation(
128-
m_object, view->GetObject(), arch->GetObject(), BNNewRelocationReference(reloc->GetObject()), dest, len);
128+
m_object, view->GetObject(), arch->GetObject(), reloc->GetObject(), dest, len);
129129
}
130130

131131

@@ -148,5 +148,5 @@ size_t CoreRelocationHandler::GetOperandForExternalRelocation(
148148
const uint8_t* data, uint64_t addr, size_t length, Ref<LowLevelILFunction> il, Ref<Relocation> relocation)
149149
{
150150
return BNRelocationHandlerGetOperandForExternalRelocation(
151-
m_object, data, addr, length, il->GetObject(), BNNewRelocationReference(relocation->GetObject()));
151+
m_object, data, addr, length, il->GetObject(), relocation->GetObject());
152152
}

0 commit comments

Comments
 (0)