From 26584b1c37576aa54f52a1977471004629b6f5bf Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Mon, 21 May 2018 21:33:16 +0200 Subject: [PATCH] codegen: Avoid critical for array in-parameters with custom length-type Regression of 049b9b3943831e6dd242889a8196bd88b7858268 --- codegen/valaccodemethodcallmodule.vala | 2 +- tests/methods/bug634753.vala | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index 2c74f2cec..14620ae35 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -356,7 +356,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); -- 2.47.2