summaryrefslogtreecommitdiff
path: root/Python/exceptions.c
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2000-07-09 22:27:10 +0000
committerBarry Warsaw <barry@python.org>2000-07-09 22:27:10 +0000
commit1059dc704f4fda1b64f396952ecd6a7c62f94e3c (patch)
treea991870f5c52c0ee40e588824c39b079f3c232f0 /Python/exceptions.c
parentda7c67c0072c9cc1045a51ee478ed65394d7f9e6 (diff)
downloadcpython-1059dc704f4fda1b64f396952ecd6a7c62f94e3c.tar.gz
Exception__str__(): In case 1, be sure to decref the tmp local
variable. This crushes another memory leak. Slight rewrite included.
Diffstat (limited to 'Python/exceptions.c')
-rw-r--r--Python/exceptions.c12
1 files changed, 8 insertions, 4 deletions
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;