[vala] Do not allow assignment with incompatible pointers
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Do not allow assignment with incompatible pointers
- Date: Mon, 18 Jan 2010 22:22:15 +0000 (UTC)
commit 950c88b51376cba2b7696d6bd11e564fd2d5a94b
Author: Marc-André Lureau <marcandre lureau gmail com>
Date: Mon Jan 18 00:42:46 2010 +0100
Do not allow assignment with incompatible pointers
That patch makes type check with pointer more strict.
Fixes bug 574486.
vala/valapointertype.vala | 17 ++++++++++++++++-
vapi/glib-2.0.vapi | 2 +-
2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/vala/valapointertype.vala b/vala/valapointertype.vala
index 76922dc..d3203f4 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 f4e1b61..b877a4a 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]