From: Rico Tzschichholz Date: Mon, 21 May 2018 19:33:16 +0000 (+0200) Subject: codegen: Avoid critical for array in-parameters with custom length-type X-Git-Tag: 0.41.90~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=920e94753e5f66a32d1a87ad3a13c1945bf84207;p=thirdparty%2Fvala.git codegen: Avoid critical for array in-parameters with custom length-type Regression of 049b9b3943831e6dd242889a8196bd88b7858268 --- diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index b2df6643a..6659442d1 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -366,7 +366,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { CCodeExpression? array_length_expr = null; if (get_ccode_array_length_type (param) != null) { string length_ctype = get_ccode_array_length_type (param); - if (unary.operator == UnaryOperator.REF) { + if (unary != null && unary.operator == UnaryOperator.REF) { length_ctype = "%s*".printf (length_ctype); } array_length_expr = new CCodeCastExpression (get_array_length_cexpression (arg, dim), length_ctype); diff --git a/tests/methods/bug634753.vala b/tests/methods/bug634753.vala index c33f44a79..9b5ad85e6 100644 --- a/tests/methods/bug634753.vala +++ b/tests/methods/bug634753.vala @@ -1,6 +1,9 @@ void foo ([CCode (array_length_type = "gsize")] ref uint8[] a) { } +void bar ([CCode (array_length_type = "gsize")] uint8[] a) { +} + void main () { uint8[] a = new uint8[32]; foo (ref a);