From 6a82099f9bfde0c6dfa3ab7bfffc1e37de16af98 Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Sun, 12 Oct 2008 20:53:26 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20556048=20=E2=80=93=20Crash=20in=20g=5Fire?= =?UTF-8?q?pository=5Ffind=5Fby=5Fgtype?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 svn path=/trunk/; revision=686 --- girepository.c | 13 +++++++++---- gtypelib.h | 7 +++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/girepository.c b/girepository.c index d56482ece..97f2627db 100644 --- a/girepository.c +++ b/girepository.c @@ -489,12 +489,17 @@ find_interface (gpointer key, { 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; diff --git a/gtypelib.h b/gtypelib.h index b71322313..54bf0523c 100644 --- a/gtypelib.h +++ b/gtypelib.h @@ -45,6 +45,13 @@ enum 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];