gobject-introspection r686 - in trunk: . girepository



Author: tko
Date: Sun Oct 12 20:53:26 2008
New Revision: 686
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=686&view=rev

Log:
Bug 556048 â Crash in g_irepository_find_by_gtype

	* girepository/gtypelib.h (BLOB_IS_REGISTERED_TYPE): added
	* girepository/girepository.c (find_interface): Fix
	find_by_gtype case to get the type name from right offset

Modified:
   trunk/ChangeLog
   trunk/girepository/girepository.c
   trunk/girepository/gtypelib.h

Modified: trunk/girepository/girepository.c
==============================================================================
--- trunk/girepository/girepository.c	(original)
+++ trunk/girepository/girepository.c	Sun Oct 12 20:53:26 2008
@@ -489,12 +489,17 @@
     {
       for (i = 1; i <= n_entries; i++)
 	{
+	  RegisteredTypeBlob *blob;
+
 	  entry = g_typelib_get_dir_entry (typelib, i);
-	  if (entry->blob_type < BLOB_TYPE_BOXED)
+	  if (!BLOB_IS_REGISTERED_TYPE (entry))
 	    continue;
-	  
-	  offset = *(guint32*)&typelib->data[entry->offset + 8];
-	  type = g_typelib_get_string (typelib, offset);
+
+	  blob = (RegisteredTypeBlob *)entry;
+	  if (!blob->gtype_name)
+	    continue;
+
+	  type = g_typelib_get_string (typelib, blob->gtype_name);
 	  if (strcmp (type, iface_data->type) == 0)
 	    {
 	      index = i;

Modified: trunk/girepository/gtypelib.h
==============================================================================
--- trunk/girepository/gtypelib.h	(original)
+++ trunk/girepository/gtypelib.h	Sun Oct 12 20:53:26 2008
@@ -45,6 +45,13 @@
   BLOB_TYPE_UNION
 };
 
+#define BLOB_IS_REGISTERED_TYPE(blob)               \
+        ((blob)->blob_type == BLOB_TYPE_STRUCT ||   \
+         (blob)->blob_type == BLOB_TYPE_UNION  ||   \
+         (blob)->blob_type == BLOB_TYPE_ENUM   ||   \
+         (blob)->blob_type == BLOB_TYPE_OBJECT ||   \
+         (blob)->blob_type == BLOB_TYPE_INTERFACE)
+
 typedef struct
 {
   gchar   magic[16];



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]