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 ef4bd1b

Browse filesBrowse files
[3.12] gh-110237: Check PyList_Append for errors in _PyEval_MatchClass (GH-110238) (#110511)
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 96e42d2 commit ef4bd1b
Copy full SHA for ef4bd1b

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
@@ -489,7 +489,9 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
489489
}
490490
if (match_self) {
491491
// Easy. Copy the subject itself, and move on to kwargs.
492-
PyList_Append(attrs, subject);
492+
if (PyList_Append(attrs, subject) < 0) {
493+
goto fail;
494+
}
493495
}
494496
else {
495497
for (Py_ssize_t i = 0; i < nargs; i++) {
@@ -505,7 +507,10 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
505507
if (attr == NULL) {
506508
goto fail;
507509
}
508-
PyList_Append(attrs, attr);
510+
if (PyList_Append(attrs, attr) < 0) {
511+
Py_DECREF(attr);
512+
goto fail;
513+
}
509514
Py_DECREF(attr);
510515
}
511516
}
@@ -518,7 +523,10 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
518523
if (attr == NULL) {
519524
goto fail;
520525
}
521-
PyList_Append(attrs, attr);
526+
if (PyList_Append(attrs, attr) < 0) {
527+
Py_DECREF(attr);
528+
goto fail;
529+
}
522530
Py_DECREF(attr);
523531
}
524532
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.