]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 23 May 2026 09:24:11 +0000 (11:24 +0200)
committerGitHub <noreply@github.com>
Sat, 23 May 2026 09:24:11 +0000 (14:54 +0530)
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 a9f811f4422e5f358e03132c4a5fdd025c7b5513..98c8cc3192a0e6d754683de68d1583fb49db775e 100644 (file)
@@ -718,6 +718,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);
@@ -1010,6 +1011,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;
                 }