Skip to content

Commit 79f1115

Browse files
committed
Fixing some memory leaks
1 parent 907b29d commit 79f1115

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

src/oid.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Handle<Value> GitOid::Sha(const Arguments& args) {
112112

113113
Handle<Value> to;
114114
to = String::New(result);
115+
free(result);
115116
return scope.Close(to);
116117
}
117118

src/patch.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ Handle<Value> GitPatch::ToString(const Arguments& args) {
319319

320320
Handle<Value> to;
321321
to = String::New(string);
322+
free(string);
322323
return scope.Close(to);
323324
}
324325

templates/convertToV8.cc.ejs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<% } else { -%>
66
to = String::New(<%- toName %>);
77
<% } -%>
8+
<% if (to.freeFunctionName) { -%>
9+
<%- to.freeFunctionName %>(<%- toName %>);
10+
<% } -%>
811
<% } else if (isV8Value(to.cppClassName)) { -%>
912
to = <%- to.cppClassName %>::New(<%- toName %>);
1013
<% } else if (to.cppClassName == "External") { -%>

v0.18.0.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,7 +3147,8 @@
31473147
"cppClassName": "String",
31483148
"jsClassName": "String",
31493149
"isReturn": true,
3150-
"comment": "Allocated string; caller must free."
3150+
"comment": "Allocated string; caller must free.",
3151+
"freeFunctionName": "free"
31513152
},
31523153
{
31533154
"name": "patch",
@@ -7622,7 +7623,8 @@
76227623
"cType": "char *",
76237624
"cppClassName": "String",
76247625
"comment": "the c-string; NULL if memory is exhausted. Caller must deallocate the string with git__free().",
7625-
"jsClassName": "String"
7626+
"jsClassName": "String",
7627+
"freeFunctionName": "free"
76267628
},
76277629
"description": "<p>Format a git_oid into a newly allocated c-string.</p>\n"
76287630
},

0 commit comments

Comments
 (0)