[pygobject] Add extra safeguard in gimodule



commit aeb85b296080a886fb71fc8b164c0760bae5bd0e
Author: Arjan Molenaar <gaphor gmail com>
Date:   Tue Aug 3 17:42:59 2021 +0200

    Add extra safeguard in gimodule
    
    Why does a g_instance_init() function only handle GObjects?

 gi/gimodule.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gi/gimodule.c b/gi/gimodule.c
index b7ef6beb..7b23012e 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -1066,11 +1066,15 @@ static void
 pygobject__g_instance_init(GTypeInstance   *instance,
                            gpointer         g_class)
 {
-    GObject *object = (GObject *) instance;
+    GObject *object;
     PyObject *wrapper, *result;
     PyGILState_STATE state;
     gboolean needs_init = FALSE;
 
+    g_return_if_fail(G_IS_OBJECT(instance));
+
+    object = (GObject *) instance;
+
     wrapper = g_object_get_qdata(object, pygobject_wrapper_key);
     if (wrapper == NULL) {
         wrapper = pygobject_init_wrapper_get();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]