[vala] codegen: Fix crash when concatenating array parameters
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Fix crash when concatenating array parameters
- Date: Sat, 16 Oct 2010 17:45:05 +0000 (UTC)
commit e58a31b5b16c1eac2425647b556499b67f7fd00a
Author: Jürg Billeter <j bitron ch>
Date: Sat Oct 16 19:41:01 2010 +0200
codegen: Fix crash when concatenating array parameters
Fixes bug 570846.
codegen/valaccodearraymodule.vala | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 094f7bf..63ada14 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<int,CCodeFormalParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]