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

svn path=/trunk/; revision=686
This commit is contained in:
Tommi Komulainen 2008-10-12 20:53:26 +00:00
parent 44172e786a
commit 6a82099f9b
2 changed files with 16 additions and 4 deletions

View File

@ -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;

View File

@ -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];