Skip to content

Commit c6c66a8

Browse files
committed
Fixes segfault issue recorded in #406
A segfault was occuring when passing null values to `NanNew`, this patch will the bug for `const char *` and `unsigned int` C types. We'll definitely need to add more in the future.
1 parent 80e4c9b commit c6c66a8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

generate/templates/partials/field_accessors.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@
122122
return;
123123
}
124124

125+
{% each field.args|argsInfo as arg %}
126+
{% if arg.name == "payload" %}
127+
{%-- Do nothing --%}
128+
{% elsif arg.isJsArg %}
129+
if (baton->{{ arg.name }} == NULL) {
130+
{% if arg.cType == "const char *" %}
131+
baton->{{ arg.name }} = "";
132+
{% elsif arg.cType == "unsigned int" %}
133+
baton->{{ arg.name }} = 0;
134+
{% endif %}
135+
}
136+
{% endif %}
137+
{% endeach %}
138+
125139
Local<Value> argv[{{ field.args|jsArgsCount }}] = {
126140
{% each field.args|argsInfo as arg %}
127141
{% if arg.name == "payload" %}

0 commit comments

Comments
 (0)