https://github.com/python/cpython/commit/ce373b845ce822a413ee8eb9bf161270825b38a2
commit: ce373b845ce822a413ee8eb9bf161270825b38a2
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-07-03T18:14:59Z
summary:

[3.15] gh-152951 - Fix double DECREF when `newblock` fails during deque.extend 
calls (GH-152961) (#152971)

gh-152951 - Fix double DECREF when `newblock` fails during deque.extend calls 
(GH-152961)
(cherry picked from commit a90576d72c8a409f7c3ffcaefafb13945e3405ab)

Co-authored-by: Steve Stagg <[email protected]>

files:
A Misc/NEWS.d/next/Library/2026-07-03-14-54-33.gh-issue-152951.u8tPCI.rst
M 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
index 00000000000000..c3d56c6d59c91b
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-07-03-14-54-33.gh-issue-152951.u8tPCI.rst
@@ -0,0 +1,2 @@
+:class:`collections.deque` prevent rare crash when calling ``extend`` under
+high memory pressure conditions.
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 5ca6362406a78b..b0701df26bbd24 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -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;
         }

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to