[gobject-introspection] girepository: avoids segfault in case of bad gtype
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] girepository: avoids segfault in case of bad gtype
- Date: Wed, 12 Jan 2022 05:49:32 +0000 (UTC)
commit c2579c71222c181068b5aaf795aa0f1e8909d89e
Author: Lukas Oberhuber <lukaso gmail com>
Date: Tue Jan 11 23:01:08 2022 +0000
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.
girepository/girepository.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 7d034859..d7f6ceb4 100644
--- a/girepository/girepository.c
+++ b/girepository/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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]