diff options
author | Paul Pogonyshev <pogonyshev@gmx.net> | 2009-04-22 21:08:49 +0300 |
---|---|---|
committer | Paul Pogonyshev <pogonyshev@gmx.net> | 2009-04-27 20:05:43 +0300 |
commit | 84706c9a73ad8b2e1dbd3eada09e4425a01d4d05 (patch) | |
tree | 9f39323c2b24ac48900e1d6429f57bd7321f7116 /gobject | |
parent | 4febd5fec7ad73a07e90bdab387125781044e86a (diff) | |
download | pygobject-84706c9a73ad8b2e1dbd3eada09e4425a01d4d05.tar.gz pygobject-84706c9a73ad8b2e1dbd3eada09e4425a01d4d05.tar.xz pygobject-84706c9a73ad8b2e1dbd3eada09e4425a01d4d05.zip |
Fix a crash in pyg_type_add_interfaces()
Reported as part of bug #566571.
Diffstat (limited to 'gobject')
-rw-r--r-- | gobject/gobjectmodule.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index aecf937..73bfc3c 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -1079,16 +1079,20 @@ pyg_type_add_interfaces(PyTypeObject *class, GType instance_type, for (i = 0; i < PyTuple_GET_SIZE(bases); ++i) { guint k; - PyTypeObject *base = (PyTypeObject *) PyTuple_GET_ITEM(bases, i); + PyObject *base = PyTuple_GET_ITEM(bases, i); GType itype; gboolean is_new = TRUE; const GInterfaceInfo *iinfo; GInterfaceInfo iinfo_copy; - if (!PyType_IsSubtype(base, &PyGInterface_Type)) + /* 'base' can also be a PyClassObject, see bug #566571. */ + if (!PyType_Check(base)) continue; - itype = pyg_type_from_object((PyObject *) base); + if (!PyType_IsSubtype((PyTypeObject*) base, &PyGInterface_Type)) + continue; + + itype = pyg_type_from_object(base); /* Happens for _implementations_ of an interface. */ if (!G_TYPE_IS_INTERFACE(itype)) @@ -1109,7 +1113,7 @@ pyg_type_add_interfaces(PyTypeObject *class, GType instance_type, gchar *error; error = g_strdup_printf("Interface type %s " "has no Python implementation support", - base->tp_name); + ((PyTypeObject *) base)->tp_name); PyErr_Warn(PyExc_RuntimeWarning, error); g_free(error); continue; |