]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-140058: Clear key and value if `PyTuple_New` fails in `dictiter_iternextitem`...
authorSergey Miryanov <sergey.miryanov@gmail.com>
Tue, 14 Oct 2025 12:45:39 +0000 (17:45 +0500)
committerGitHub <noreply@github.com>
Tue, 14 Oct 2025 12:45:39 +0000 (18:15 +0530)
Objects/dictobject.c

index ddf9bde63f31bb3dd1297514c5f89ee2a0c243e0..b95a4a8dc5efec3d2e585c1abab6e82df6e0935b 100644 (file)
@@ -5719,8 +5719,11 @@ dictiter_iternextitem(PyObject *self)
         }
         else {
             result = PyTuple_New(2);
-            if (result == NULL)
+            if (result == NULL) {
+                Py_DECREF(key);
+                Py_DECREF(value);
                 return NULL;
+            }
             PyTuple_SET_ITEM(result, 0, key);
             PyTuple_SET_ITEM(result, 1, value);
         }