From bac0f34e54d114815dd9f9573271eb03e62cdc69 Mon Sep 17 00:00:00 2001 From: "mhammond%skippinet.com.au" Date: Wed, 2 Apr 2003 03:59:18 +0000 Subject: [PATCH] If repr() of a component failed we would crash. Not part of the build. git-svn-id: svn://10.0.0.236/trunk@140546 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/python/xpcom/src/PyGBase.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mozilla/extensions/python/xpcom/src/PyGBase.cpp b/mozilla/extensions/python/xpcom/src/PyGBase.cpp index 86b5762b343..bd1b29e1203 100644 --- a/mozilla/extensions/python/xpcom/src/PyGBase.cpp +++ b/mozilla/extensions/python/xpcom/src/PyGBase.cpp @@ -89,7 +89,14 @@ PyG_Base::PyG_Base(PyObject *instance, const nsIID &iid) // If XPCOM reference count logging is enabled, then allow us to give the Python class. PyObject *realInstance = PyObject_GetAttrString(instance, "_obj_"); PyObject *r = PyObject_Repr(realInstance); - const char *szRepr = PyString_AsString(r); + const char *szRepr; + if (r==NULL) { + PyXPCOM_LogError("Getting the __repr__ of the object failed"); + PyErr_Clear(); + szRepr = "(repr failed!)"; + } + else + szRepr = PyString_AsString(r); if (szRepr==NULL) szRepr = ""; int reprOffset = *szRepr=='<' ? 1 : 0; static const char *reprPrefix = "component:";