mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.11] gh-110237: Check PyList_Append for errors in _PyEval_MatchClass (GH-110238) (#110512)
gh-110237: Check `PyList_Append` for errors in `_PyEval_MatchClass` (GH-110238)
(cherry picked from commit dd9d781da3)
Co-authored-by: denballakh <47365157+denballakh@users.noreply.github.com>
This commit is contained in:
parent
af168df78f
commit
f21c09ca03
2 changed files with 12 additions and 3 deletions
|
|
@ -0,0 +1 @@
|
||||||
|
Fix missing error checks for calls to ``PyList_Append`` in ``_PyEval_MatchClass``.
|
||||||
|
|
@ -1060,7 +1060,9 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
|
||||||
}
|
}
|
||||||
if (match_self) {
|
if (match_self) {
|
||||||
// Easy. Copy the subject itself, and move on to kwargs.
|
// Easy. Copy the subject itself, and move on to kwargs.
|
||||||
PyList_Append(attrs, subject);
|
if (PyList_Append(attrs, subject) < 0) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (Py_ssize_t i = 0; i < nargs; i++) {
|
for (Py_ssize_t i = 0; i < nargs; i++) {
|
||||||
|
|
@ -1076,7 +1078,10 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
|
||||||
if (attr == NULL) {
|
if (attr == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
PyList_Append(attrs, attr);
|
if (PyList_Append(attrs, attr) < 0) {
|
||||||
|
Py_DECREF(attr);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
Py_DECREF(attr);
|
Py_DECREF(attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1089,7 +1094,10 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
|
||||||
if (attr == NULL) {
|
if (attr == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
PyList_Append(attrs, attr);
|
if (PyList_Append(attrs, attr) < 0) {
|
||||||
|
Py_DECREF(attr);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
Py_DECREF(attr);
|
Py_DECREF(attr);
|
||||||
}
|
}
|
||||||
Py_SETREF(attrs, PyList_AsTuple(attrs));
|
Py_SETREF(attrs, PyList_AsTuple(attrs));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue