diff options
author | Georg Brandl <georg@python.org> | 2007-02-26 13:48:28 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-02-26 13:48:28 +0000 |
commit | 76183a853c84f1b4ef649667502089e2f065149c (patch) | |
tree | de806af66fe0d9eae77a787a5b659d9c79e0d876 /Objects/stringobject.c | |
parent | 3bfc747dd6f0fe4753efecc0f8765fbade234b28 (diff) | |
download | cpython-76183a853c84f1b4ef649667502089e2f065149c.tar.gz |
Fix a refleak in PyString_Format.
Diffstat (limited to 'Objects/stringobject.c')
-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 d772e74c07..7212df904e 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -4780,10 +4780,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; } @@ -4834,6 +4837,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); |