]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-150178: Fix refcount leaks in hamt allocation failure paths (#150179)
authorpengyu lee <lipengyu@kylinos.cn>
Sat, 23 May 2026 08:33:40 +0000 (16:33 +0800)
committerGitHub <noreply@github.com>
Sat, 23 May 2026 08:33:40 +0000 (14:03 +0530)
Python/hamt.c

index e4719e71a5259a57c67538615b388f7b2180d4a7..95998ae5062ac7e72819eeac280a36cb4d33e9e3 100644 (file)
@@ -702,6 +702,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);
@@ -994,6 +995,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;
                 }