diff Python/exceptions.c @ 13484:67fd19d74528 legacy-trunk

Exception__str__(): In case 1, be sure to decref the tmp local variable. This crushes another memory leak. Slight rewrite included.
author Barry Warsaw <barry@python.org>
date Sun, 09 Jul 2000 22:27:10 +0000
parents d6198e703602
children feab677269e0
line wrap: on
line diff
--- a/Python/exceptions.c	Sun Jul 09 21:24:31 2000 +0000
+++ b/Python/exceptions.c	Sun Jul 09 22:27:10 2000 +0000
@@ -231,7 +231,6 @@
 Exception__str__(PyObject* self, PyObject* args)
 {
     PyObject* out;
-    PyObject* tmp;
 
     if (!PyArg_ParseTuple(args, "O", &self))
         return NULL;
@@ -245,11 +244,16 @@
         out = PyString_FromString("");
         break;
     case 1:
-	if (!(tmp = PySequence_GetItem(args, 0)))
-	    out = NULL;
+    {
+	PyObject* tmp = PySequence_GetItem(args, 0);
+	if (tmp) {
+	    out = PyObject_Str(tmp);
+	    Py_DECREF(tmp);
+	}
 	else
-	    out = PyObject_Str(tmp);
+	    out = NULL;
 	break;
+    }
     default:
         out = PyObject_Str(args);
         break;