From e58a31b5b16c1eac2425647b556499b67f7fd00a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrg=20Billeter?= Date: Sat, 16 Oct 2010 19:41:01 +0200 Subject: [PATCH] codegen: Fix crash when concatenating array parameters Fixes bug 570846. --- codegen/valaccodearraymodule.vala | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala index 094f7bfd..63ada14b 100644 --- a/codegen/valaccodearraymodule.vala +++ b/codegen/valaccodearraymodule.vala @@ -783,12 +783,23 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule { return; } - var binary = assignment.right as BinaryExpression; + var binary = (BinaryExpression) assignment.right; var array = binary.left; var array_type = (ArrayType) array.value_type; var element = binary.right; + var array_var = assignment.left.symbol_reference; + var array_local = array_var as LocalVariable; + if (array_type.rank == 1 && array_var != null && array_var.is_internal_symbol () + && ((array_var is LocalVariable && !array_local.captured) || array_var is Field)) { + // valid array add + } else { + Report.error (assignment.source_reference, "Array concatenation not supported for public array variables and parameters"); + set_cvalue (assignment, new CCodeInvalidExpression ()); + return; + } + var value_param = new FormalParameter ("value", element.target_type); var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_array_add_wrapper (array_type))); @@ -798,15 +809,6 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule { ccall.add_argument (handle_struct_argument (value_param, element, get_cvalue (element))); set_cvalue (assignment, ccall); - - var array_var = assignment.left.symbol_reference; - var array_local = array_var as LocalVariable; - if (array_type.rank == 1 && array_var != null && array_var.is_internal_symbol () - && ((array_var is LocalVariable && !array_local.captured) || array_var is Field)) { - // valid array add - } else { - Report.error (assignment.source_reference, "Array concatenation not supported for public array variables"); - } } public override CCodeFormalParameter generate_parameter (FormalParameter param, CCodeFile decl_space, Map cparam_map, Map? carg_map) { -- 2.11.4.GIT