girepository: avoids segfault in case of bad gtype

If a <GType invalid> (that's the way it appears in python's debugger) is
returned, `g_type_name` returns NULL. This
function therefore returns NULL at this time
as subsequent calls to `strlen( data->gtype_name)` segfault.
This commit is contained in:
Lukas Oberhuber 2022-01-11 23:01:08 +00:00 committed by Philip Chimento
parent 3d999b47e5
commit 6583ad7f4f

View File

@ -806,12 +806,14 @@ find_by_gtype (GHashTable *table, FindByGTypeData *data, gboolean check_prefix)
*/
GIBaseInfo *
g_irepository_find_by_gtype (GIRepository *repository,
GType gtype)
GType gtype)
{
FindByGTypeData data;
GIBaseInfo *cached;
DirEntry *entry;
g_return_val_if_fail (gtype != G_TYPE_INVALID, NULL);
repository = get_repository (repository);
cached = g_hash_table_lookup (repository->priv->info_by_gtype,