Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-110237: Check PyList_Append for errors in _PyEval_MatchClass #110238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 8, 2023
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`
denballakh marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 11 additions & 3 deletions 14 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) {
JelleZijlstra marked this conversation as resolved.
Show resolved Hide resolved
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.