From: Barry Warsaw Date: Sun, 9 Jul 2000 22:27:10 +0000 (+0000) Subject: Exception__str__(): In case 1, be sure to decref the tmp local X-Git-Tag: v2.0b1~947 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b78165566ef353187f00419cb9c1c18e5dae1383;p=python Exception__str__(): In case 1, be sure to decref the tmp local variable. This crushes another memory leak. Slight rewrite included. --- diff --git a/Python/exceptions.c b/Python/exceptions.c index c32e15ccbc..f766ba5ef3 100644 --- a/Python/exceptions.c +++ b/Python/exceptions.c @@ -231,7 +231,6 @@ static PyObject* Exception__str__(PyObject* self, PyObject* args) { PyObject* out; - PyObject* tmp; if (!PyArg_ParseTuple(args, "O", &self)) return NULL; @@ -245,11 +244,16 @@ Exception__str__(PyObject* self, PyObject* args) out = PyString_FromString(""); break; case 1: - if (!(tmp = PySequence_GetItem(args, 0))) - out = NULL; - else + { + PyObject* tmp = PySequence_GetItem(args, 0); + if (tmp) { out = PyObject_Str(tmp); + Py_DECREF(tmp); + } + else + out = NULL; break; + } default: out = PyObject_Str(args); break;