[vala/0.38] codegen: Avoid critical for array in-parameters with custom length-type



commit 9f0b816fb2c4dca3ecc67bcf25eb3b9f04dd4a82
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon May 21 21:33:16 2018 +0200

    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 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 2a2eb24..310135f 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -364,7 +364,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 c33f44a..9b5ad85 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]