]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix cast from non-array to array type
authorJürg Billeter <j@bitron.ch>
Mon, 10 Aug 2009 18:51:10 +0000 (20:51 +0200)
committerJürg Billeter <j@bitron.ch>
Mon, 10 Aug 2009 18:52:27 +0000 (20:52 +0200)
Fixes bug 590785.

codegen/valaccodearraymodule.vala
codegen/valaccodebasemodule.vala

index 515c4919f95d34efae24d710c6099e71e6cf51bb..4520974202a4f34bc691a20537b946bbbe1c70fe 100644 (file)
@@ -163,7 +163,9 @@ internal class Vala.CCodeArrayModule : CCodeMethodCallModule {
                        return (CCodeExpression) get_ccodenode (length_expr);
                } else if (array_expr is MethodCall || array_expr is CastExpression) {
                        Gee.List<CCodeExpression> size = array_expr.get_array_sizes ();
-                       return size[dim - 1];
+                       if (size.size >= dim) {
+                               return size[dim - 1];
+                       }
                } else if (array_expr.symbol_reference != null) {
                        if (array_expr.symbol_reference is FormalParameter) {
                                var param = (FormalParameter) array_expr.symbol_reference;
@@ -276,7 +278,9 @@ internal class Vala.CCodeArrayModule : CCodeMethodCallModule {
                                var prop = (Property) array_expr.symbol_reference;
                                if (!prop.no_array_length) {
                                        Gee.List<CCodeExpression> size = array_expr.get_array_sizes ();
-                                       return size[dim - 1];
+                                       if (size.size >= dim) {
+                                               return size[dim - 1];
+                                       }
                                }
                        }
                } else if (array_expr is NullLiteral) {
index 21506b19130ca72681eaa01ec085110e5d12ee4a..6005a64faebda53b13b495fc4c385622ecfc90fb 100644 (file)
@@ -3444,7 +3444,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
 
                        // retain array length
                        var array_type = expr.type_reference as ArrayType;
-                       if (array_type != null) {
+                       if (array_type != null && expr.inner.value_type is ArrayType) {
                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                        expr.append_array_size (get_array_length_cexpression (expr.inner, dim));
                                }