Commit 18847c92 authored by Rico Tzschichholz's avatar Rico Tzschichholz

codegen: Dup arrays only if length > 0, this consistently returns NULL (POSIX)

parent e66d2192
......@@ -529,6 +529,10 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
push_context (new EmitContext ());
push_function (function);
// only attempt to dup if length > 0, this consistently returns NULL
var clengthcheck = new CCodeBinaryExpression (CCodeBinaryOperator.GREATER_THAN, new CCodeIdentifier ("length"), new CCodeConstant ("0"));
ccode.open_if (clengthcheck);
if (requires_copy (array_type.element_type)) {
var cvardecl = new CCodeVariableDeclarator ("result");
CCodeFunctionCall gnew;
......@@ -599,6 +603,9 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
}
}
ccode.close ();
ccode.add_return (new CCodeIdentifier ("NULL"));
// append to file
cfile.add_function_declaration (function);
......
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