diff Objects/stringobject.c @ 40925:621443fc01bb legacy-trunk

Backport from Py3k branch: fix refleak in PyString_Format.
author Georg Brandl <georg@python.org>
date Mon, 26 Feb 2007 13:51:29 +0000
parents d01bd37bf5ce
children cedc8d7d1c7f
line wrap: on
line diff
--- a/Objects/stringobject.c	Sun Feb 25 22:12:31 2007 +0000
+++ b/Objects/stringobject.c	Mon Feb 26 13:51:29 2007 +0000
@@ -4767,10 +4767,13 @@
 				reslen += rescnt;
 				if (reslen < 0) {
 					Py_DECREF(result);
+					Py_XDECREF(temp);
 					return PyErr_NoMemory();
 				}
-				if (_PyString_Resize(&result, reslen) < 0)
+				if (_PyString_Resize(&result, reslen) < 0) {
+					Py_XDECREF(temp);
 					return NULL;
+				}
 				res = PyString_AS_STRING(result)
 					+ reslen - rescnt;
 			}
@@ -4821,6 +4824,7 @@
                         if (dict && (argidx < arglen) && c != '%') {
                                 PyErr_SetString(PyExc_TypeError,
                                            "not all arguments converted during string formatting");
+                                Py_XDECREF(temp);
                                 goto error;
                         }
 			Py_XDECREF(temp);