summaryrefslogtreecommitdiff
path: root/relocationhandler.cpp
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2023-01-31 21:45:23 -0500
committerAlexander Taylor <alex@vector35.com>2023-02-08 11:53:38 -0500
commitc2247a35e97c96eba9cd4caf09b32b038625cc31 (patch)
treed88022f286bd811667f88cc3926dada7b4ec5d31 /relocationhandler.cpp
parent0b752f36c9d3b6bcb51a05fdcf5b38633d38bdbd (diff)
Clean up possible early deletion issues in API callbacks
Diffstat (limited to 'relocationhandler.cpp')
-rw-r--r--relocationhandler.cpp6
1 files changed, 3 insertions, 3 deletions
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<RelocationHandler> handler(ctxt);
Ref<BinaryView> viewObj = new BinaryView(BNNewViewReference(view));
Ref<Architecture> 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<RelocationHandler> handler(ctxt);
Ref<Architecture> archObj = new CoreArchitecture(arch);
Ref<BinaryView> viewObj = new BinaryView(BNNewViewReference(view));
Ref<Relocation> 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<RelocationHandler> handler(ctxt);
Ref<LowLevelILFunction> func(new LowLevelILFunction(BNNewLowLevelILFunctionReference(il)));
Ref<Relocation> relocObj = new Relocation(BNNewRelocationReference(reloc));
return handler->GetOperandForExternalRelocation(data, addr, length, func, relocObj);