]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-109700: fix memory error handling in `PyDict_SetDefault` (#136338) (#136642)
authorKumar Aditya <kumaraditya@python.org>
Mon, 14 Jul 2025 08:25:31 +0000 (13:55 +0530)
committerGitHub <noreply@github.com>
Mon, 14 Jul 2025 08:25:31 +0000 (08:25 +0000)
gh-109700: fix memory error handling in `PyDict_SetDefault` (#136338)

(cherry picked from commit d22e073d2b49313bbf42d40cbe74afa2b69385df)

Misc/NEWS.d/next/Core and Builtins/2025-07-06-14-53-19.gh-issue-109700.KVNQQi.rst [new file with mode: 0644]
Objects/dictobject.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2025-07-06-14-53-19.gh-issue-109700.KVNQQi.rst b/Misc/NEWS.d/next/Core and Builtins/2025-07-06-14-53-19.gh-issue-109700.KVNQQi.rst
new file mode 100644 (file)
index 0000000..a37f4a5
--- /dev/null
@@ -0,0 +1 @@
+Fix memory error handling in :c:func:`PyDict_SetDefault`.
index baac54911f0371fb6123208f1ea9cbf87a891398..69a69e13faefe661d82e40d84a53c7e89475b39b 100644 (file)
@@ -4340,6 +4340,7 @@ dict_setdefault_ref_lock_held(PyObject *d, PyObject *key, PyObject *default_valu
             if (result) {
                 *result = NULL;
             }
+            return -1;
         }
 
         MAINTAIN_TRACKING(mp, key, value);