]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-152951 - Fix double DECREF when `newblock` fails during deque.extend calls (#152961)
authorSteve Stagg <stestagg@gmail.com>
Fri, 3 Jul 2026 17:43:24 +0000 (18:43 +0100)
committerGitHub <noreply@github.com>
Fri, 3 Jul 2026 17:43:24 +0000 (20:43 +0300)
Misc/NEWS.d/next/Library/2026-07-03-14-54-33.gh-issue-152951.u8tPCI.rst [new file with mode: 0644]
Modules/_collectionsmodule.c

diff --git a/Misc/NEWS.d/next/Library/2026-07-03-14-54-33.gh-issue-152951.u8tPCI.rst b/Misc/NEWS.d/next/Library/2026-07-03-14-54-33.gh-issue-152951.u8tPCI.rst
new file mode 100644 (file)
index 0000000..c3d56c6
--- /dev/null
@@ -0,0 +1,2 @@
+:class:`collections.deque` prevent rare crash when calling ``extend`` under
+high memory pressure conditions.
index e96a546a818d3d75b8403f1fda6138d12cb9d345..62d1dad5735ec8eb6967e94b1f4ca7e0ef943cd4 100644 (file)
@@ -512,7 +512,6 @@ deque_extend_impl(dequeobject *deque, PyObject *iterable)
     iternext = *Py_TYPE(it)->tp_iternext;
     while ((item = iternext(it)) != NULL) {
         if (deque_append_lock_held(deque, item, maxlen) == -1) {
-            Py_DECREF(item);
             Py_DECREF(it);
             return NULL;
         }