Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Check PyList_Append for errors in _PyEval_MatchClass
  • Loading branch information
denballakh committed Oct 2, 2023
commit 600883f645aa287f8d96900acef5459d58797811
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check `PyList_Append` for errors in `_PyEval_MatchClass`
Comment thread
denballakh marked this conversation as resolved.
Outdated
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) == -1) {
Comment thread
JelleZijlstra marked this conversation as resolved.
Outdated
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) == -1) {
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) == -1) {
Py_DECREF(attr);
goto fail;
}
Py_DECREF(attr);
}
Py_SETREF(attrs, PyList_AsTuple(attrs));
Expand Down