From 6583ad7f4f57e65c9193481afd936566ada94fc3 Mon Sep 17 00:00:00 2001 From: Lukas Oberhuber Date: Tue, 11 Jan 2022 23:01:08 +0000 Subject: [PATCH] girepository: avoids segfault in case of bad gtype If a (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. --- girepository.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/girepository.c b/girepository.c index 7d0348598..d7f6ceb4d 100644 --- a/girepository.c +++ b/girepository.c @@ -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,