Fix crash when using multi-dimensional arrays, patch by Amos Brocco, fixes
authorJürg Billeter <j@bitron.ch>
Tue, 22 Jul 2008 14:50:59 +0000 (14:50 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Tue, 22 Jul 2008 14:50:59 +0000 (14:50 +0000)
2008-07-22  Jürg Billeter  <j@bitron.ch>

* gobject/valaccodearraycreationexpressionbinding.vala:

Fix crash when using multi-dimensional arrays,
patch by Amos Brocco, fixes bug 544145

svn path=/trunk/; revision=1721

ChangeLog
THANKS
gobject/valaccodearraycreationexpressionbinding.vala

index bfdba0e..6127550 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2008-07-22  Jürg Billeter  <j@bitron.ch>
 
+       * gobject/valaccodearraycreationexpressionbinding.vala:
+
+       Fix crash when using multi-dimensional arrays,
+       patch by Amos Brocco, fixes bug 544145
+
+2008-07-22  Jürg Billeter  <j@bitron.ch>
+
        * vala/valaparser.vala:
 
        Fix regression introduced by last commit
diff --git a/THANKS b/THANKS
index 0671c84..450afa9 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -3,6 +3,7 @@ The Vala team would like to thank the following contributors:
 Alberto Ruiz
 Alexandre Moreira
 Ali Sabil
+Amos Brocco
 Andrea Del Signore
 Andreas Brauchli
 Arwed von Merkatz
index b002fd8..4db9a3f 100644 (file)
@@ -44,6 +44,8 @@ public class Vala.CCodeArrayCreationExpressionBinding : CCodeExpressionBinding {
                gnew.add_argument (new CCodeIdentifier (expr.element_type.get_cname ()));
                bool first = true;
                CCodeExpression cexpr = null;
+
+               // iterate over each dimension
                foreach (Expression size in expr.get_sizes ()) {
                        CCodeExpression csize = (CCodeExpression) size.ccodenode;
 
@@ -57,11 +59,6 @@ public class Vala.CCodeArrayCreationExpressionBinding : CCodeExpressionBinding {
                                csize = new CCodeParenthesizedExpression (new CCodeAssignment (name_cnode, csize));
                        }
 
-                       if (expr.element_type.data_type != null && expr.element_type.data_type.is_reference_type ()) {
-                               // add extra item to have array NULL-terminated for all reference types
-                               csize = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, csize, new CCodeConstant ("1"));
-                       }
-
                        if (first) {
                                cexpr = csize;
                                first = false;
@@ -69,6 +66,12 @@ public class Vala.CCodeArrayCreationExpressionBinding : CCodeExpressionBinding {
                                cexpr = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, cexpr, csize);
                        }
                }
+               
+               // add extra item to have array NULL-terminated for all reference types
+               if (expr.element_type.data_type != null && expr.element_type.data_type.is_reference_type ()) {
+                       cexpr = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cexpr, new CCodeConstant ("1"));
+               }
+               
                gnew.add_argument (cexpr);
 
                if (expr.initializer_list != null) {