[vala] Fix crash on invalid field initializer
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Fix crash on invalid field initializer
- Date: Mon, 22 Mar 2010 22:28:13 +0000 (UTC)
commit 918c07568d44aae0fb3ba30e83f58c866dddeeb3
Author: Jürg Billeter <j bitron ch>
Date: Mon Mar 22 23:27:33 2010 +0100
Fix crash on invalid field initializer
Fixes bug 608635.
vala/valafield.vala | 8 +++++++-
vala/valaproperty.vala | 4 ++--
2 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/vala/valafield.vala b/vala/valafield.vala
index 87d12c1..b038c72 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 e00a21b..ac15b8e 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 ()));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]