From: Marc-André Lureau Date: Sun, 17 Jan 2010 23:42:46 +0000 (+0100) Subject: Do not allow assignment with incompatible pointers X-Git-Tag: 0.7.10~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=950c88b51376cba2b7696d6bd11e564fd2d5a94b;p=thirdparty%2Fvala.git Do not allow assignment with incompatible pointers That patch makes type check with pointer more strict. Fixes bug 574486. --- diff --git a/vala/valapointertype.vala b/vala/valapointertype.vala index 76922dcc9..d3203f461 100644 --- a/vala/valapointertype.vala +++ b/vala/valapointertype.vala @@ -62,7 +62,22 @@ public class Vala.PointerType : DataType { } public override bool compatible (DataType target_type) { - if (target_type is PointerType || (target_type.data_type != null && target_type.data_type.get_attribute ("PointerType") != null)) { + if (target_type is PointerType) { + var tt = target_type as PointerType; + + if (tt.base_type is VoidType || base_type is VoidType) { + return true; + } + + /* dereference only if both types are references or not */ + if (base_type.is_reference_type_or_type_parameter () != tt.base_type.is_reference_type_or_type_parameter ()) { + return false; + } + + return base_type.compatible (tt.base_type); + } + + if ((target_type.data_type != null && target_type.data_type.get_attribute ("PointerType") != null)) { return true; } diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index f4e1b61a0..b877a4a0e 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -1007,7 +1007,7 @@ public class string { string* result = GLib.malloc0 (this.size () - ((char*) end_string - (char*) start_string) + str_size + 1); - char* dest = result; + char* dest = (char*) result; GLib.Memory.copy (dest, this, (char*) start_string - (char*) this); dest += (char*) start_string - (char*) this;