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

Commit f21c09c

Browse filesBrowse files
[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 dd9d781) Co-authored-by: denballakh <47365157+denballakh@users.noreply.github.com>
1 parent af168df commit f21c09c
Copy full SHA for f21c09c

File tree

2 files changed

+12
-3
lines changed
Filter options

2 files changed

+12
-3
lines changed
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix missing error checks for calls to ``PyList_Append`` in ``_PyEval_MatchClass``.

‎Python/ceval.c

Copy file name to clipboardExpand all lines: Python/ceval.c
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,9 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
10601060
}
10611061
if (match_self) {
10621062
// Easy. Copy the subject itself, and move on to kwargs.
1063-
PyList_Append(attrs, subject);
1063+
if (PyList_Append(attrs, subject) < 0) {
1064+
goto fail;
1065+
}
10641066
}
10651067
else {
10661068
for (Py_ssize_t i = 0; i < nargs; i++) {
@@ -1076,7 +1078,10 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
10761078
if (attr == NULL) {
10771079
goto fail;
10781080
}
1079-
PyList_Append(attrs, attr);
1081+
if (PyList_Append(attrs, attr) < 0) {
1082+
Py_DECREF(attr);
1083+
goto fail;
1084+
}
10801085
Py_DECREF(attr);
10811086
}
10821087
}
@@ -1089,7 +1094,10 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
10891094
if (attr == NULL) {
10901095
goto fail;
10911096
}
1092-
PyList_Append(attrs, attr);
1097+
if (PyList_Append(attrs, attr) < 0) {
1098+
Py_DECREF(attr);
1099+
goto fail;
1100+
}
10931101
Py_DECREF(attr);
10941102
}
10951103
Py_SETREF(attrs, PyList_AsTuple(attrs));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.