Backport from Py3k branch: fix refleak in PyString_Format.

This commit is contained in:
Georg Brandl 2007-02-26 13:51:29 +00:00
parent 110054c053
commit 10a4b0e6df
1 changed files with 5 additions and 1 deletions

View File

@ -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);