summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authordenballakh <47365157+denballakh@users.noreply.github.com>2023-10-08 00:04:51 (GMT)
committerGitHub <noreply@github.com>2023-10-08 00:04:51 (GMT)
commitdd9d781da30aa3740e54c063a40413c542d78c25 (patch)
tree68d6b82652c7b224897411f3c70be6beeb910cd2 /Python/ceval.c
parentde2a4036cbfd5e41a5bdd2b81122b7765729af83 (diff)
downloadcpython-dd9d781da30aa3740e54c063a40413c542d78c25.zip
cpython-dd9d781da30aa3740e54c063a40413c542d78c25.tar.gz
cpython-dd9d781da30aa3740e54c063a40413c542d78c25.tar.bz2
gh-110237: Check `PyList_Append` for errors in `_PyEval_MatchClass` (#110238)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index cae29e0..ac40425 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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) < 0) {
+ goto fail;
+ }
}
else {
for (Py_ssize_t i = 0; i < nargs; i++) {
@@ -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) < 0) {
+ Py_DECREF(attr);
+ goto fail;
+ }
Py_DECREF(attr);
}
}
@@ -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) < 0) {
+ Py_DECREF(attr);
+ goto fail;
+ }
Py_DECREF(attr);
}
Py_SETREF(attrs, PyList_AsTuple(attrs));