diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-10-08 00:29:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-08 00:29:46 (GMT) |
commit | f21c09ca03b39319ee6de54f5d706bd6e2313985 (patch) | |
tree | 7f4b633ba43844042ae42b7d81652749a6642445 /Python | |
parent | af168df78f260a809875b309f35fbf38b58c1fec (diff) | |
download | cpython-f21c09ca03b39319ee6de54f5d706bd6e2313985.zip cpython-f21c09ca03b39319ee6de54f5d706bd6e2313985.tar.gz cpython-f21c09ca03b39319ee6de54f5d706bd6e2313985.tar.bz2 |
[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 dd9d781da30aa3740e54c063a40413c542d78c25)
Co-authored-by: denballakh <47365157+denballakh@users.noreply.github.com>
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 14 |
1 files changed, 11 insertions, 3 deletions
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)); |