diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-10-08 00:40:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-08 00:40:38 (GMT) |
commit | ef4bd1b57ff2b0a908149d178b0b1fbdf9f7e247 (patch) | |
tree | 815aafc61ca324271c1d0f2cb917c0307edb58cf /Python/ceval.c | |
parent | 96e42d2f8d1fbc1c15ee02aab17ee209174d4b39 (diff) | |
download | cpython-ef4bd1b57ff2b0a908149d178b0b1fbdf9f7e247.zip cpython-ef4bd1b57ff2b0a908149d178b0b1fbdf9f7e247.tar.gz cpython-ef4bd1b57ff2b0a908149d178b0b1fbdf9f7e247.tar.bz2 |
[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 dd9d781da30aa3740e54c063a40413c542d78c25)
Co-authored-by: denballakh <47365157+denballakh@users.noreply.github.com>
Diffstat (limited to 'Python/ceval.c')
-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 fdb5b72..4845ec0 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -489,7 +489,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++) { @@ -505,7 +507,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); } } @@ -518,7 +523,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)); |