diff options
author | John Ehresman <jpe@wingware.com> | 2010-04-11 22:14:39 -0400 |
---|---|---|
committer | John Ehresman <jpe@wingware.com> | 2010-04-15 12:13:34 -0400 |
commit | d8109d9de81a776794965d4cc1093ca03bebd6af (patch) | |
tree | 54e99689dc2767c4fa01d84cfa1ae510c89d5091 /glib | |
parent | 13a5da14842caa6a80e6ed7237422b984a152cd8 (diff) | |
download | pygobject-d8109d9de81a776794965d4cc1093ca03bebd6af.tar.gz pygobject-d8109d9de81a776794965d4cc1093ca03bebd6af.tar.xz pygobject-d8109d9de81a776794965d4cc1093ca03bebd6af.zip |
Fix reference leak when using repr in exception strings
Diffstat (limited to 'glib')
-rw-r--r-- | glib/glibmodule.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/glib/glibmodule.c b/glib/glibmodule.c index f794d5d..c529f87 100644 --- a/glib/glibmodule.c +++ b/glib/glibmodule.c @@ -558,9 +558,12 @@ static PyObject* pyglib_set_application_name(PyObject *self, PyObject *arg) { if (!PyString_Check(arg)) { + PyObject *repr = PyObject_Repr(arg); + const char *repr_ptr = (repr ? PyString_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "first argument must be a string, not '%s'", - PyString_AS_STRING(PyObject_Repr(arg))); + (repr_ptr ? repr_ptr : "<?>")); + Py_CLEAR(repr); return NULL; } g_set_application_name(PyString_AS_STRING(arg)); @@ -585,9 +588,12 @@ static PyObject* pyglib_set_prgname(PyObject *self, PyObject *arg) { if (!PyString_Check(arg)) { + PyObject *repr = PyObject_Repr(arg); + const char *repr_ptr = (repr ? PyString_AsString(repr) : "<?>"); PyErr_Format(PyExc_TypeError, "first argument must be a string, not '%s'", - PyString_AS_STRING(PyObject_Repr(arg))); + (repr_ptr ? repr_ptr : "<?>")); + Py_CLEAR(repr); return NULL; } g_set_prgname(PyString_AS_STRING(arg)); |