summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-02-26 13:51:29 (GMT)
committerGeorg Brandl <georg@python.org>2007-02-26 13:51:29 (GMT)
commit10a4b0e6df1e33e2f2f4be43dc1c4af8098f0fb0 (patch)
tree609cf159c6d44dac24245d9e36bf784c7e23a7a4 /Objects
parent110054c0535dd8291cef0fe9b473bf1e819b2ef6 (diff)
downloadcpython-10a4b0e6df1e33e2f2f4be43dc1c4af8098f0fb0.zip
cpython-10a4b0e6df1e33e2f2f4be43dc1c4af8098f0fb0.tar.gz
cpython-10a4b0e6df1e33e2f2f4be43dc1c4af8098f0fb0.tar.bz2
Backport from Py3k branch: fix refleak in PyString_Format.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/stringobject.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index ca94d72..64be0de 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -4767,10 +4767,13 @@ PyString_Format(PyObject *format, PyObject *args)
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 @@ PyString_Format(PyObject *format, PyObject *args)
if (dict && (argidx < arglen) && c != '%') {
PyErr_SetString(PyExc_TypeError,
"not all arguments converted during string formatting");
+ Py_XDECREF(temp);
goto error;
}
Py_XDECREF(temp);