[Python-3000-checkins] r53934 - python/branches/p3yk/Objects/stringobject.c

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


Author: georg.brandl
Date: Mon Feb 26 14:48:28 2007
New Revision: 53934

Modified:
   python/branches/p3yk/Objects/stringobject.c
Log:
Fix a refleak in PyString_Format.



Modified: python/branches/p3yk/Objects/stringobject.c
==============================================================================
--- python/branches/p3yk/Objects/stringobject.c	(original)
+++ python/branches/p3yk/Objects/stringobject.c	Mon Feb 26 14:48:28 2007
@@ -4780,10 +4780,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;
 			}
@@ -4834,6 +4837,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-3000-checkins mailing list