From: Rico Tzschichholz Date: Wed, 27 May 2020 07:22:32 +0000 (+0200) Subject: Revert "codegen: Dup arrays only if length > 0, this consistently returns NULL (POSIX)" X-Git-Tag: 0.49.1~118 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2903dcaf009afbe08b4a8ce22e892e6003c1ccc;p=thirdparty%2Fvala.git Revert "codegen: Dup arrays only if length > 0, this consistently returns NULL (POSIX)" This reverts commit 18847c9221362081c9a9d37e2922f3e3ea648088. Fixes https://gitlab.gnome.org/GNOME/vala/issues/999 --- diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala index ee0fa7780..5fa9ea23d 100644 --- a/codegen/valaccodearraymodule.vala +++ b/codegen/valaccodearraymodule.vala @@ -529,10 +529,6 @@ 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; @@ -603,9 +599,6 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule { } } - ccode.close (); - ccode.add_return (new CCodeIdentifier ("NULL")); - // append to file cfile.add_function_declaration (function);