Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix missing error checks for calls to ``PyList_Append`` in ``_PyEval_MatchClass``.
14 changes: 11 additions & 3 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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);
}
}
Expand All @@ -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));
Expand Down