diff options
author | Georg Brandl <georg@python.org> | 2007-02-26 13:51:29 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-02-26 13:51:29 (GMT) |
commit | 10a4b0e6df1e33e2f2f4be43dc1c4af8098f0fb0 (patch) | |
tree | 609cf159c6d44dac24245d9e36bf784c7e23a7a4 /Objects | |
parent | 110054c0535dd8291cef0fe9b473bf1e819b2ef6 (diff) | |
download | cpython-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.c | 6 |
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); |