Visitar URL original
Fix memory leaks by julianmesa-gitkraken · Pull Request #1944 · nodegit/nodegit · GitHub
Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Free baton on error processing javascript arguments
We only free baton on some cases, but we should try to free all previously allocated memory.
  • Loading branch information
julianmesa-gitkraken committed Oct 26, 2022
commit 7b5c85b7e063cb4e305364a2cf7474bf9490a4b0
5 changes: 4 additions & 1 deletion generate/templates/partials/async_function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
);

if (!conversionResult.result) {
delete[] baton->{{ arg.name }};
// TODO free previously allocated memory
free(baton->{{ arg.name }});
delete baton;
return Nan::ThrowError(Nan::New(conversionResult.error).ToLocalChecked());
}

Expand All @@ -77,6 +79,7 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
{
auto conversionResult = Configurable{{ arg.cppClassName }}::fromJavascript(nodegitContext, info[{{ arg.jsArg }}]);
if (!conversionResult.result) {
delete baton;
return Nan::ThrowError(Nan::New(conversionResult.error).ToLocalChecked());
}

Expand Down