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
Fix leak strdup in oid
  • Loading branch information
julianmesa-gitkraken committed Oct 25, 2022
commit 9eb357eda4b1cda94108fbdda62e527938d9398d
8 changes: 4 additions & 4 deletions generate/templates/partials/convert_from_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
if (arrayVal->IsString()) {
// Try and parse in a string to a git_oid
Nan::Utf8String oidString(Nan::To<v8::String>(arrayVal).ToLocalChecked());

if (git_oid_fromstr(&from_{{ name }}[i], (const char *) strdup(*oidString)) != GIT_OK) {
string str = string(*oidString);
if (git_oid_fromstr(&from_{{ name }}[i], str.c_str()) != GIT_OK) {
if (git_error_last()) {
return Nan::ThrowError(git_error_last()->message);
} else {
Expand Down Expand Up @@ -90,8 +90,8 @@
// Try and parse in a string to a git_oid
Nan::Utf8String oidString(Nan::To<v8::String>(info[{{ jsArg }}]).ToLocalChecked());
git_oid *oidOut = (git_oid *)malloc(sizeof(git_oid));

if (git_oid_fromstr(oidOut, (const char *) strdup(*oidString)) != GIT_OK) {
string str = string(*oidString);
if (git_oid_fromstr(oidOut, str.c_str()) != GIT_OK) {
free(oidOut);

if (git_error_last()) {
Expand Down