From: Jürg Billeter Date: Mon, 22 Mar 2010 22:27:33 +0000 (+0100) Subject: Fix crash on invalid field initializer X-Git-Tag: 0.8.0~67 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=918c07568d44aae0fb3ba30e83f58c866dddeeb3;p=thirdparty%2Fvala.git Fix crash on invalid field initializer Fixes bug 608635. --- diff --git a/vala/valafield.vala b/vala/valafield.vala index 87d12c12c..b038c729f 100644 --- a/vala/valafield.vala +++ b/vala/valafield.vala @@ -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 ())); diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala index e00a21b8c..ac15b8e85 100644 --- a/vala/valaproperty.vala +++ b/vala/valaproperty.vala @@ -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 ())); }