]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-152951 - Fix double DECREF when `newblock` fails during deque.extend calls...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 3 Jul 2026 18:14:59 +0000 (20:14 +0200)
committerGitHub <noreply@github.com>
Fri, 3 Jul 2026 18:14:59 +0000 (18:14 +0000)
gh-152951 - Fix double DECREF when `newblock` fails during deque.extend calls (GH-152961)
(cherry picked from commit a90576d72c8a409f7c3ffcaefafb13945e3405ab)

Co-authored-by: Steve Stagg <stestagg@gmail.com>
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 5ca6362406a78b9c57227fe5784cf4de7d9190d5..b0701df26bbd24cafd734e991529819e8e98447b 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;
         }