Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ce7d1e

Browse files
committed
Fix a refleak in PyString_Format.
1 parent 80b331c commit 6ce7d1e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Objects/stringobject.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4780,10 +4780,13 @@ PyString_Format(PyObject *format, PyObject *args)
47804780
reslen += rescnt;
47814781
if (reslen < 0) {
47824782
Py_DECREF(result);
4783+
Py_XDECREF(temp);
47834784
return PyErr_NoMemory();
47844785
}
4785-
if (_PyString_Resize(&result, reslen) < 0)
4786+
if (_PyString_Resize(&result, reslen) < 0) {
4787+
Py_XDECREF(temp);
47864788
return NULL;
4789+
}
47874790
res = PyString_AS_STRING(result)
47884791
+ reslen - rescnt;
47894792
}
@@ -4834,6 +4837,7 @@ PyString_Format(PyObject *format, PyObject *args)
48344837
if (dict && (argidx < arglen) && c != '%') {
48354838
PyErr_SetString(PyExc_TypeError,
48364839
"not all arguments converted during string formatting");
4840+
Py_XDECREF(temp);
48374841
goto error;
48384842
}
48394843
Py_XDECREF(temp);

0 commit comments

Comments
 (0)