summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2023-10-02-23-17-08.gh-issue-110237._Xub0z.rst1
-rw-r--r--Python/ceval.c14
2 files changed, 12 insertions, 3 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-10-02-23-17-08.gh-issue-110237._Xub0z.rst b/Misc/NEWS.d/next/Core and Builtins/2023-10-02-23-17-08.gh-issue-110237._Xub0z.rst
new file mode 100644
index 0000000..67b95c5
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2023-10-02-23-17-08.gh-issue-110237._Xub0z.rst
@@ -0,0 +1 @@
+Fix missing error checks for calls to ``PyList_Append`` in ``_PyEval_MatchClass``.
diff --git a/Python/ceval.c b/Python/ceval.c
index df11de0..172bc47 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1060,7 +1060,9 @@ match_class(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) < 0) {
+ goto fail;
+ }
}
else {
for (Py_ssize_t i = 0; i < nargs; i++) {
@@ -1076,7 +1078,10 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
if (attr == NULL) {
goto fail;
}
- PyList_Append(attrs, attr);
+ if (PyList_Append(attrs, attr) < 0) {
+ Py_DECREF(attr);
+ goto fail;
+ }
Py_DECREF(attr);
}
}
@@ -1089,7 +1094,10 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
if (attr == NULL) {
goto fail;
}
- PyList_Append(attrs, attr);
+ if (PyList_Append(attrs, attr) < 0) {
+ Py_DECREF(attr);
+ goto fail;
+ }
Py_DECREF(attr);
}
Py_SETREF(attrs, PyList_AsTuple(attrs));