Skip to content

Commit

Permalink
Free debugger core allocated strings in BNDebuggerRegisterEventCallba…
Browse files Browse the repository at this point in the history
…ck rather then DebuggerController::DebuggerEventCallback
  • Loading branch information
xusheng6 committed Feb 1, 2023
1 parent ae406d2 commit b1f63d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 0 additions & 4 deletions api/debuggercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,20 +665,16 @@ void DebuggerController::DebuggerEventCallback(void* ctxt, BNDebuggerEvent* even

evt.data.errorData.error = string(event->data.errorData.error);
evt.data.errorData.shortError = string(event->data.errorData.shortError);
BNDebuggerFreeString(event->data.errorData.error);
BNDebuggerFreeString(event->data.errorData.shortError);
evt.data.errorData.data = event->data.errorData.data;

evt.data.exitData.exitCode = event->data.exitData.exitCode;

evt.data.relativeAddress.module = string(event->data.relativeAddress.module);
BNDebuggerFreeString(event->data.relativeAddress.module);
evt.data.relativeAddress.offset = event->data.relativeAddress.offset;

evt.data.absoluteAddress = event->data.absoluteAddress;

evt.data.messageData.message = string(event->data.messageData.message);
BNDebuggerFreeString(event->data.messageData.message);

object->action(evt);
}
Expand Down
5 changes: 5 additions & 0 deletions core/ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,11 @@ size_t BNDebuggerRegisterEventCallback(
evt->data.messageData.message = BNDebuggerAllocString(event.data.messageData.message.c_str());

callback(ctx, evt);

BNDebuggerFreeString(evt->data.errorData.error);
BNDebuggerFreeString(evt->data.errorData.shortError);
BNDebuggerFreeString(evt->data.relativeAddress.module);
BNDebuggerFreeString(evt->data.messageData.message);
delete evt;
},
name);
Expand Down

0 comments on commit b1f63d4

Please sign in to comment.