mirror of https://github.com/python/cpython
Backport from Py3k branch: fix refleak in PyString_Format.
(backport from rev. 53935)
This commit is contained in:
parent
25e7cfa4b9
commit
5f795865da
|
@ -4764,10 +4764,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;
|
||||
}
|
||||
|
@ -4818,6 +4821,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);
|
||||
|
|
Loading…
Reference in New Issue