From 073e04dcbbb90fdff8bebfbbd3a68bdd9d285954 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Wed, 30 Jul 2025 13:00:12 -0700 Subject: 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. --- relocationhandler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'relocationhandler.cpp') 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 view, Ref arch, Ref 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 view, Ref arch, Ref 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 il, Ref relocation) { return BNRelocationHandlerGetOperandForExternalRelocation( - m_object, data, addr, length, il->GetObject(), BNNewRelocationReference(relocation->GetObject())); + m_object, data, addr, length, il->GetObject(), relocation->GetObject()); } -- cgit v1.3.1