From 95886775af564a05aaaf5708f0b37279f82d0d76 Mon Sep 17 00:00:00 2001 From: Paul Pogonyshev Date: Wed, 3 Dec 2008 19:45:41 +0000 Subject: Test if `domain' is not-null before using it (avoids segfaults, see bug 2008-12-03 Paul Pogonyshev * glib/pyglib.c (pyglib_error_check): Test if `domain' is not-null before using it (avoids segfaults, see bug #561826). svn path=/trunk/; revision=976 --- glib/pyglib.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'glib/pyglib.c') diff --git a/glib/pyglib.c b/glib/pyglib.c index 4dabb19..4001708 100644 --- a/glib/pyglib.c +++ b/glib/pyglib.c @@ -270,9 +270,14 @@ pyglib_error_check(GError **error) } exc_instance = PyObject_CallFunction(exc_type, "z", (*error)->message); - PyObject_SetAttrString(exc_instance, "domain", - d=_PyUnicode_FromString(g_quark_to_string((*error)->domain))); - Py_DECREF(d); + + if ((*error)->domain) { + PyObject_SetAttrString(exc_instance, "domain", + d=_PyUnicode_FromString(g_quark_to_string((*error)->domain))); + Py_DECREF(d); + } + else + PyObject_SetAttrString(exc_instance, "domain", Py_None); PyObject_SetAttrString(exc_instance, "code", d=_PyLong_FromLong((*error)->code)); -- cgit