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 dd9d781

Browse filesBrowse files
authored
gh-110237: Check PyList_Append for errors in _PyEval_MatchClass (#110238)
1 parent de2a403 commit dd9d781
Copy full SHA for dd9d781

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
@@ -506,7 +506,9 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
506506
}
507507
if (match_self) {
508508
// Easy. Copy the subject itself, and move on to kwargs.
509-
PyList_Append(attrs, subject);
509+
if (PyList_Append(attrs, subject) < 0) {
510+
goto fail;
511+
}
510512
}
511513
else {
512514
for (Py_ssize_t i = 0; i < nargs; i++) {
@@ -522,7 +524,10 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
522524
if (attr == NULL) {
523525
goto fail;
524526
}
525-
PyList_Append(attrs, attr);
527+
if (PyList_Append(attrs, attr) < 0) {
528+
Py_DECREF(attr);
529+
goto fail;
530+
}
526531
Py_DECREF(attr);
527532
}
528533
}
@@ -535,7 +540,10 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
535540
if (attr == NULL) {
536541
goto fail;
537542
}
538-
PyList_Append(attrs, attr);
543+
if (PyList_Append(attrs, attr) < 0) {
544+
Py_DECREF(attr);
545+
goto fail;
546+
}
539547
Py_DECREF(attr);
540548
}
541549
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.