Commit d77f4188 authored by Tyler Wanek's avatar Tyler Wanek Committed by GitHub

Merge pull request #1368 from cjhoward92/fix_large_buffer_crashes

Fixed an issue where large buffer allocations in filters (> 256MB) causes a segfault
parents c737c25c 658f5b7a
......@@ -173,7 +173,8 @@
"out": {
"isReturn": true,
"cppClassName": "GitBuf",
"jsClassName": "Buffer"
"jsClassName": "Buffer",
"shouldAlloc": true
},
"blob": {
"cppClassName": "GitBlob",
......@@ -259,7 +260,8 @@
"isReturn": true,
"cppClassName": "GitBuf",
"jsClassName": "Buffer",
"cType": "git_buf *"
"cType": "git_buf *",
"shouldAlloc": true
},
"repo": {
"cppClassName": "GitRepository",
......@@ -307,9 +309,9 @@
"jsFunctionName": "grow",
"args": {
"buffer": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
"isReturn": false,
"isSelf": true,
"shouldAlloc": false
}
},
"return": {
......@@ -324,9 +326,9 @@
"jsFunctionName": "set",
"args": {
"buffer": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
"isReturn": false,
"isSelf": true,
"shouldAlloc": false
},
"data": {
"cppClassName": "Buffer",
......@@ -537,6 +539,19 @@
"return": {
"ownedByThis": true
}
},
"git_commit_header_field": {
"isAsync": true,
"args": {
"out": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
}
},
"return": {
"isErrorCode": true
}
}
}
},
......@@ -601,6 +616,12 @@
},
"git_config_get_string_buf": {
"isAsync": true,
"args": {
"out": {
"isReturn": true,
"shouldAlloc": true
}
},
"return": {
"isErrorCode": true
}
......@@ -673,6 +694,19 @@
"return": {
"isErrorCode": true
}
},
"git_config_find_programdata": {
"isAsync": true,
"return": {
"isErrorCode": true
},
"args": {
"out": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
}
}
}
},
"dependencies": [
......@@ -882,6 +916,19 @@
"git_diff_status_char": {
"ignore": true
},
"git_diff_to_buf": {
"isAsync": true,
"return": {
"isErrorCode": true
},
"args": {
"out": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
}
}
},
"git_diff_tree_to_index": {
"args": {
"old_tree": {
......@@ -1968,7 +2015,9 @@
"isAsync": true,
"args": {
"out": {
"isReturn": true
"isReturn": true,
"shouldAlloc": true,
"isSelf": false
},
"remote": {
"isSelf": true
......@@ -2115,6 +2164,13 @@
"isAsync": true,
"return": {
"isErrorCode": true
},
"args": {
"out": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
}
}
},
"git_repository_init_init_options": {
......@@ -2478,6 +2534,19 @@
"isErrorCode": true
}
},
"git_submodule_resolve_url": {
"isAsync": true,
"args": {
"out": {
"isReturn": true,
"shouldAlloc": true,
"isSelf": false
}
},
"return": {
"isErrorCode": true
}
},
"git_submodule_update": {
"isAsync": true,
"args": {
......
......@@ -15,15 +15,6 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
{%if arg.globalPayload %}
{{ cppFunctionName }}_globalPayload* globalPayload = new {{ cppFunctionName }}_globalPayload;
{%endif%}
{%if arg.cppClassName == "GitBuf" %}
{%if cppFunctionName == "Set"%}
baton->{{arg.name}} = Nan::ObjectWrap::Unwrap<{{ arg.cppClassName }}>(info.This())->GetValue();
{%else%}
baton->{{arg.name}} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }}));
baton->{{arg.name}}->ptr = NULL;
baton->{{arg.name}}->size = baton->{{arg.name}}->asize = 0;
{%endif%}
{%endif%}
{%endeach%}
{%each args|argsInfo as arg %}
......@@ -61,9 +52,10 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
{%endif%}
{%endif%}
{%elsif arg.shouldAlloc %}
baton->{{arg.name}} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }}));
{%if arg.cppClassName == "GitBuf" %}
{%else%}
baton->{{ arg.name }} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }}));
baton->{{arg.name}}->ptr = NULL;
baton->{{arg.name}}->size = baton->{{arg.name}}->asize = 0;
{%endif%}
{%endif%}
{%endeach%}
......
......@@ -43,12 +43,16 @@
to = tmpArray;
{% elsif cppClassName == 'GitBuf' %}
{% if doNotConvert %}
to = Nan::Null();
{% else %}
if ({{= parsedName =}}) {
to = Nan::New<String>({{= parsedName =}}->ptr, {{= parsedName = }}->size).ToLocalChecked();
}
else {
to = Nan::Null();
}
{% endif %}
{% else %}
{% if copy %}
if ({{= parsedName =}} != NULL) {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment