]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix crash on invalid field initializer
authorJürg Billeter <j@bitron.ch>
Mon, 22 Mar 2010 22:27:33 +0000 (23:27 +0100)
committerJürg Billeter <j@bitron.ch>
Mon, 22 Mar 2010 22:27:33 +0000 (23:27 +0100)
Fixes bug 608635.

vala/valafield.vala
vala/valaproperty.vala

index 87d12c12c0534cefb4526d643f915bfddf011bde..b038c729f08ccf7c53b71db8053d0f77de62c09a 100644 (file)
@@ -1,6 +1,6 @@
 /* valafield.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -324,6 +324,12 @@ public class Vala.Field : Member, Lockable {
                                return false;
                        }
 
+                       if (initializer.value_type == null) {
+                               error = true;
+                               Report.error (source_reference, "expression type not allowed as initializer");
+                               return false;
+                       }
+
                        if (!initializer.value_type.compatible (field_type)) {
                                error = true;
                                Report.error (source_reference, "Cannot convert from `%s' to `%s'".printf (initializer.value_type.to_string (), field_type.to_string ()));
index e00a21b8c004ecac095f20242013d1a468df15db..ac15b8e854d3cf4c45bec428e88ac22c6bf67622 100644 (file)
@@ -1,6 +1,6 @@
 /* valaproperty.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -471,7 +471,7 @@ public class Vala.Property : Member, Lockable {
                        }
                }
 
-               if (default_expression != null && !default_expression.error && !(default_expression.value_type.compatible (property_type))) {
+               if (default_expression != null && !default_expression.error && default_expression.value_type != null && !(default_expression.value_type.compatible (property_type))) {
                        error = true;
                        Report.error (default_expression.source_reference, "Expected initializer of type `%s' but got `%s'".printf (property_type.to_string (), default_expression.value_type.to_string ()));
                }