mirror of https://github.com/python/cpython
gh-110237: Check `PyList_Append` for errors in `_PyEval_MatchClass` (#110238)
This commit is contained in:
parent
de2a4036cb
commit
dd9d781da3
|
@ -0,0 +1 @@
|
|||
Fix missing error checks for calls to ``PyList_Append`` in ``_PyEval_MatchClass``.
|
|
@ -506,7 +506,9 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
|
|||
}
|
||||
if (match_self) {
|
||||
// Easy. Copy the subject itself, and move on to kwargs.
|
||||
PyList_Append(attrs, subject);
|
||||
if (PyList_Append(attrs, subject) < 0) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Py_ssize_t i = 0; i < nargs; i++) {
|
||||
|
@ -522,7 +524,10 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
|
|||
if (attr == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
PyList_Append(attrs, attr);
|
||||
if (PyList_Append(attrs, attr) < 0) {
|
||||
Py_DECREF(attr);
|
||||
goto fail;
|
||||
}
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
}
|
||||
|
@ -535,7 +540,10 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
|
|||
if (attr == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
PyList_Append(attrs, attr);
|
||||
if (PyList_Append(attrs, attr) < 0) {
|
||||
Py_DECREF(attr);
|
||||
goto fail;
|
||||
}
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
Py_SETREF(attrs, PyList_AsTuple(attrs));
|
||||
|
|
Loading…
Reference in New Issue