mirror of
https://github.com/python/cpython.git
synced 2025-10-11 17:32:49 +00:00
set_repr(): handle correctly PyUnicode_FromUnicode() error (MemoryError)
Bug found by the Clang Static Analyzer.
This commit is contained in:
parent
5572ba7e15
commit
a1a807b6ef
1 changed files with 11 additions and 9 deletions
|
@ -607,7 +607,9 @@ set_repr(PySetObject *so)
|
||||||
goto done;
|
goto done;
|
||||||
newsize = PyUnicode_GET_SIZE(listrepr);
|
newsize = PyUnicode_GET_SIZE(listrepr);
|
||||||
result = PyUnicode_FromUnicode(NULL, newsize);
|
result = PyUnicode_FromUnicode(NULL, newsize);
|
||||||
if (result) {
|
if (result == NULL)
|
||||||
|
goto done;
|
||||||
|
|
||||||
u = PyUnicode_AS_UNICODE(result);
|
u = PyUnicode_AS_UNICODE(result);
|
||||||
*u++ = '{';
|
*u++ = '{';
|
||||||
/* Omit the brackets from the listrepr */
|
/* Omit the brackets from the listrepr */
|
||||||
|
@ -615,8 +617,8 @@ set_repr(PySetObject *so)
|
||||||
newsize-2);
|
newsize-2);
|
||||||
u += newsize-2;
|
u += newsize-2;
|
||||||
*u = '}';
|
*u = '}';
|
||||||
}
|
|
||||||
Py_DECREF(listrepr);
|
Py_DECREF(listrepr);
|
||||||
|
|
||||||
if (Py_TYPE(so) != &PySet_Type) {
|
if (Py_TYPE(so) != &PySet_Type) {
|
||||||
PyObject *tmp = PyUnicode_FromFormat("%s(%U)",
|
PyObject *tmp = PyUnicode_FromFormat("%s(%U)",
|
||||||
Py_TYPE(so)->tp_name,
|
Py_TYPE(so)->tp_name,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue