]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 24 May 2026 07:42:21 +0000 (09:42 +0200)
committerGitHub <noreply@github.com>
Sun, 24 May 2026 07:42:21 +0000 (07:42 +0000)
gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179)
(cherry picked from commit 32823af153b76b7042fbce28ea8a6e0c3c4f1ca8)

Co-authored-by: pengyu lee <lipengyu@kylinos.cn>
Python/hamt.c

index 881290a0e60db87b0815a68fb87a534dbd332b48..98ef96df2c54e375a162d802b1a571f9d3287955 100644 (file)
@@ -701,6 +701,7 @@ hamt_node_bitmap_assoc(PyHamtNode_Bitmap *self,
 
             PyHamtNode_Bitmap *ret = hamt_node_bitmap_clone(self);
             if (ret == NULL) {
+                Py_DECREF(sub_node);
                 return NULL;
             }
             Py_SETREF(ret->b_array[val_idx], (PyObject*)sub_node);
@@ -993,6 +994,7 @@ hamt_node_bitmap_without(PyHamtNode_Bitmap *self,
 
                 PyHamtNode_Bitmap *clone = hamt_node_bitmap_clone(self);
                 if (clone == NULL) {
+                    Py_DECREF(sub_node);
                     return W_ERROR;
                 }