From c2247a35e97c96eba9cd4caf09b32b038625cc31 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 31 Jan 2023 21:45:23 -0500 Subject: Clean up possible early deletion issues in API callbacks --- relocationhandler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'relocationhandler.cpp') diff --git a/relocationhandler.cpp b/relocationhandler.cpp index d1233ad0..045e9fa6 100644 --- a/relocationhandler.cpp +++ b/relocationhandler.cpp @@ -54,7 +54,7 @@ void RelocationHandler::FreeCallback(void* ctxt) bool RelocationHandler::GetRelocationInfoCallback( void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocationInfo* result, size_t resultCount) { - RelocationHandler* handler = (RelocationHandler*)ctxt; + CallbackRef handler(ctxt); Ref viewObj = new BinaryView(BNNewViewReference(view)); Ref archObj = new CoreArchitecture(arch); if (!result) @@ -70,7 +70,7 @@ bool RelocationHandler::GetRelocationInfoCallback( bool RelocationHandler::ApplyRelocationCallback( void* ctxt, BNBinaryView* view, BNArchitecture* arch, BNRelocation* reloc, uint8_t* dest, size_t len) { - RelocationHandler* handler = (RelocationHandler*)ctxt; + CallbackRef handler(ctxt); Ref archObj = new CoreArchitecture(arch); Ref viewObj = new BinaryView(BNNewViewReference(view)); Ref relocObj = new Relocation(BNNewRelocationReference(reloc)); @@ -81,7 +81,7 @@ bool RelocationHandler::ApplyRelocationCallback( size_t RelocationHandler::GetOperandForExternalRelocationCallback( void* ctxt, const uint8_t* data, uint64_t addr, size_t length, BNLowLevelILFunction* il, BNRelocation* reloc) { - RelocationHandler* handler = (RelocationHandler*)ctxt; + CallbackRef handler(ctxt); Ref func(new LowLevelILFunction(BNNewLowLevelILFunctionReference(il))); Ref relocObj = new Relocation(BNNewRelocationReference(reloc)); return handler->GetOperandForExternalRelocation(data, addr, length, func, relocObj); -- cgit v1.3.1