diff options
author | kcatss <kcats9731@gmail.com> | 2024-02-14 16:08:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-14 16:08:26 (GMT) |
commit | 671360161f0b7a5ff4c1d062e570962e851b4bde (patch) | |
tree | 35a1478dce33d64c60507acbb843c822dad9abd2 /Modules/_collectionsmodule.c | |
parent | 81e140d10b77f0a41a5581412e3f3471cc77981f (diff) | |
download | cpython-671360161f0b7a5ff4c1d062e570962e851b4bde.zip cpython-671360161f0b7a5ff4c1d062e570962e851b4bde.tar.gz cpython-671360161f0b7a5ff4c1d062e570962e851b4bde.tar.bz2 |
gh-115243: Fix crash in deque.index() when the deque is concurrently modified (GH-115247)
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r-- | Modules/_collectionsmodule.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index ef77d34..4fa76d6 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1218,8 +1218,9 @@ deque_index_impl(dequeobject *deque, PyObject *v, Py_ssize_t start, n = stop - i; while (--n >= 0) { CHECK_NOT_END(b); - item = b->data[index]; + item = Py_NewRef(b->data[index]); cmp = PyObject_RichCompareBool(item, v, Py_EQ); + Py_DECREF(item); if (cmp > 0) return PyLong_FromSsize_t(stop - n - 1); if (cmp < 0) |