[Python-checkins] r53935 - python/trunk/Objects/stringobject.c

georg.brandl python-checkins at python.org
Mon Feb 26 14:51:31 CET 2007


Author: georg.brandl
Date: Mon Feb 26 14:51:29 2007
New Revision: 53935

Modified:
   python/trunk/Objects/stringobject.c
Log:
Backport from Py3k branch: fix refleak in PyString_Format.


Modified: python/trunk/Objects/stringobject.c
==============================================================================
--- python/trunk/Objects/stringobject.c	(original)
+++ python/trunk/Objects/stringobject.c	Mon Feb 26 14:51:29 2007
@@ -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);


More information about the Python-checkins mailing list