From: Juerg Billeter Date: Sat, 19 Apr 2008 09:00:48 +0000 (+0000) Subject: fix crash when trying to iterate over pointer types, fixes bug 528765 X-Git-Tag: VALA_0_3_1~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78674ebd37deb0bd6b209ebe236685c96371889f;p=platform%2Fupstream%2Fvala.git fix crash when trying to iterate over pointer types, fixes bug 528765 2008-04-19 Juerg Billeter * vala/valasemanticanalyzer.vala, gobject/valaccodegenerator.vala: fix crash when trying to iterate over pointer types, fixes bug 528765 svn path=/trunk/; revision=1267 --- diff --git a/ChangeLog b/ChangeLog index b1f128d..4f78569 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-04-19 Jürg Billeter + * vala/valasemanticanalyzer.vala, gobject/valaccodegenerator.vala: + fix crash when trying to iterate over pointer types, + fixes bug 528765 + +2008-04-19 Jürg Billeter + * vala/valadelegatetype.vala: fix to_string for nullable delegates * vapi/packages/gtk+-2.0/: fix gtk_about_dialog_set_*_hook diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index 6655cfc..97ef134 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -102,17 +102,17 @@ public class Vala.CCodeGenerator : CodeGenerator { public Typesymbol gtypeinstance_type; public Typesymbol gobject_type; public ErrorType gerror_type; - public Typesymbol glist_type; - public Typesymbol gslist_type; + public Class glist_type; + public Class gslist_type; public Typesymbol gstringbuilder_type; public Typesymbol garray_type; public DataType gquark_type; public DataType mutex_type; public Typesymbol type_module_type; - public Typesymbol iterable_type; - public Typesymbol iterator_type; - public Typesymbol list_type; - public Typesymbol map_type; + public Interface iterable_type; + public Interface iterator_type; + public Interface list_type; + public Interface map_type; public Typesymbol connection_type; public Method substring_method; @@ -226,8 +226,8 @@ public class Vala.CCodeGenerator : CodeGenerator { gtypeinstance_type = (Typesymbol) glib_ns.scope.lookup ("TypeInstance"); gobject_type = (Typesymbol) glib_ns.scope.lookup ("Object"); gerror_type = new ErrorType (null, null); - glist_type = (Typesymbol) glib_ns.scope.lookup ("List"); - gslist_type = (Typesymbol) glib_ns.scope.lookup ("SList"); + glist_type = (Class) glib_ns.scope.lookup ("List"); + gslist_type = (Class) glib_ns.scope.lookup ("SList"); gstringbuilder_type = (Typesymbol) glib_ns.scope.lookup ("StringBuilder"); garray_type = (Typesymbol) glib_ns.scope.lookup ("Array"); @@ -249,10 +249,10 @@ public class Vala.CCodeGenerator : CodeGenerator { var gee_ns = root_symbol.scope.lookup ("Gee"); if (gee_ns != null) { - iterable_type = (Typesymbol) gee_ns.scope.lookup ("Iterable"); - iterator_type = (Typesymbol) gee_ns.scope.lookup ("Iterator"); - list_type = (Typesymbol) gee_ns.scope.lookup ("List"); - map_type = (Typesymbol) gee_ns.scope.lookup ("Map"); + iterable_type = (Interface) gee_ns.scope.lookup ("Iterable"); + iterator_type = (Interface) gee_ns.scope.lookup ("Iterator"); + list_type = (Interface) gee_ns.scope.lookup ("List"); + map_type = (Interface) gee_ns.scope.lookup ("Map"); } var dbus_ns = root_symbol.scope.lookup ("DBus"); @@ -1897,8 +1897,7 @@ public class Vala.CCodeGenerator : CodeGenerator { cfor.add_iterator (new CCodeAssignment (new CCodeIdentifier (it_name), new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier (it_name), new CCodeConstant ("1")))); cblock.add_statement (cfor); } - } else if (stmt.collection.static_type.data_type == glist_type || - stmt.collection.static_type.data_type == gslist_type) { + } else if (stmt.collection.static_type.compatible (new ClassType (glist_type)) || stmt.collection.static_type.compatible (new ClassType (gslist_type))) { var it_name = "%s_it".printf (stmt.variable_name); var citdecl = new CCodeDeclaration (collection_type.get_cname ()); @@ -1950,7 +1949,7 @@ public class Vala.CCodeGenerator : CodeGenerator { cfor.add_iterator (new CCodeAssignment (new CCodeIdentifier (it_name), new CCodeMemberAccess.pointer (new CCodeIdentifier (it_name), "next"))); cblock.add_statement (cfor); - } else if (stmt.collection.static_type.data_type.is_subtype_of (iterable_type)) { + } else if (iterable_type != null && stmt.collection.static_type.compatible (new InterfaceType (iterable_type))) { var it_name = "%s_it".printf (stmt.variable_name); var citdecl = new CCodeDeclaration (iterator_type.get_cname () + "*"); diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index dc7e2f2..67d2289 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -2553,6 +2553,11 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } if (expr.inner.static_type is PointerType) { var pointer_type = (PointerType) expr.inner.static_type; + if (pointer_type.base_type is ReferenceType) { + expr.error = true; + Report.error (expr.source_reference, "Pointer indirection not supported for this expression"); + return; + } expr.static_type = pointer_type.base_type; } else { expr.error = true;