Visitar URL original
Free baton on error processing javascript arguments · nodegit/nodegit@7b5c85b · GitHub
Skip to content

Commit 7b5c85b

Browse files
Free baton on error processing javascript arguments
We only free baton on some cases, but we should try to free all previously allocated memory.
1 parent 07a4593 commit 7b5c85b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎generate/templates/partials/async_function.cc‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
6464
);
6565

6666
if (!conversionResult.result) {
67-
delete[] baton->{{ arg.name }};
67+
// TODO free previously allocated memory
68+
free(baton->{{ arg.name }});
69+
delete baton;
6870
return Nan::ThrowError(Nan::New(conversionResult.error).ToLocalChecked());
6971
}
7072

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

0 commit comments

Comments
 (0)