Skip to content
Merged
Show file tree
Hide file tree
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
Next Next commit
Fix Alloc-Dealloc Mismatches
  • Loading branch information
zawata committed Nov 26, 2025
commit 03b5353ca55c67a1ffdb3c4dc42a5d6fb19cf7de
14 changes: 7 additions & 7 deletions generate/templates/manual/repository/refresh_references.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ class RefreshedRefModel {
}

~RefreshedRefModel() {
if (fullName != NULL) { delete[] fullName; }
if (message != NULL) { delete[] message; }
if (fullName != NULL) { free(fullName); }
if (message != NULL) { free(message); }
delete[] sha;
if (shorthand != NULL) { delete[] shorthand; }
if (shorthand != NULL) { free(shorthand); }
if (tagOdbBuffer != NULL) { delete[] tagOdbBuffer; }
}

Expand Down Expand Up @@ -344,8 +344,8 @@ class UpstreamModel {
}

~UpstreamModel() {
if (downstreamFullName != NULL) { delete[] downstreamFullName; }
if (upstreamFullName != NULL) { delete[] upstreamFullName; }
if (downstreamFullName != NULL) { free(downstreamFullName); }
if (upstreamFullName != NULL) { free(upstreamFullName); }
}

char *downstreamFullName;
Expand Down Expand Up @@ -375,7 +375,7 @@ class RefreshReferencesData {
delete upstreamInfo.back();
upstreamInfo.pop_back();
}
if (headRefFullName != NULL) { delete[] headRefFullName; }
if (headRefFullName != NULL) { free(headRefFullName); }
if (cherrypick != NULL) { delete cherrypick; }
if (merge != NULL) { delete merge; }
}
Expand Down Expand Up @@ -573,7 +573,7 @@ void GitRepository::RefreshReferencesWorker::Execute()
if (isRemote) {
char *remoteNameOfRef = getRemoteNameOfReference(reference);
bool isFromExistingRemote = gitStrArrayContains(&remoteNames, remoteNameOfRef);
delete[] remoteNameOfRef;
free(remoteNameOfRef);
if (!isFromExistingRemote) {
git_reference_free(reference);
continue;
Expand Down
8 changes: 8 additions & 0 deletions generate/templates/manual/revwalk/file_history_walk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ class FileHistoryEvent {
if (commit != NULL) {
git_commit_free(commit);
}

if(from != NULL) {
Comment thread
ianhattendorf marked this conversation as resolved.
free((void *)from);
}

if(to != NULL) {
free((void *)to);
}
}

v8::Local<v8::Value> toJavascript() {
Expand Down
4 changes: 2 additions & 2 deletions generate/templates/templates/struct_content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Configurable{{ cppClassName }}::Configurable{{ cppClassName }}(nodegit::Context
this->raw = new {{ cType }};
{% else %}
{{ cType }}{% if isExtendedStruct %}_extended{% endif %} wrappedValue = {{ cType|upper }}_INIT;
this->raw = ({{ cType }}*) malloc(sizeof({{ cType }}{% if isExtendedStruct %}_extended{% endif %}));
this->raw = ({{ cType }}*) new {{ cType }}{% if isExtendedStruct %}_extended{% endif %};
memcpy(this->raw, &wrappedValue, sizeof({{ cType }}{% if isExtendedStruct %}_extended{% endif %}));
{% endif %}
}
Expand All @@ -132,7 +132,7 @@ Configurable{{ cppClassName }}::~Configurable{{ cppClassName }}() {
{% if field.cppClassName == 'GitStrarray' %}
if (this->raw->{{ field.name }}.count) {
for (size_t i = 0; i < this->raw->{{ field.name }}.count; ++i) {
delete this->raw->{{ field.name }}.strings[i];
free(this->raw->{{ field.name }}.strings[i]);
}
delete[] this->raw->{{ field.name }}.strings;
}
Expand Down