mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
Fix a refleak in PyString_Format.
This commit is contained in:
parent
80b331cb30
commit
6ce7d1ed55
1 changed files with 5 additions and 1 deletions
|
@ -4780,10 +4780,13 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
reslen += rescnt;
|
reslen += rescnt;
|
||||||
if (reslen < 0) {
|
if (reslen < 0) {
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
|
Py_XDECREF(temp);
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
if (_PyString_Resize(&result, reslen) < 0)
|
if (_PyString_Resize(&result, reslen) < 0) {
|
||||||
|
Py_XDECREF(temp);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
res = PyString_AS_STRING(result)
|
res = PyString_AS_STRING(result)
|
||||||
+ reslen - rescnt;
|
+ reslen - rescnt;
|
||||||
}
|
}
|
||||||
|
@ -4834,6 +4837,7 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
if (dict && (argidx < arglen) && c != '%') {
|
if (dict && (argidx < arglen) && c != '%') {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"not all arguments converted during string formatting");
|
"not all arguments converted during string formatting");
|
||||||
|
Py_XDECREF(temp);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
Py_XDECREF(temp);
|
Py_XDECREF(temp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue