Skip to content

Commit 224045a

Browse files
lpyu001miss-islington
authored andcommitted
gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179)
(cherry picked from commit 32823af) Co-authored-by: pengyu lee <lipengyu@kylinos.cn>
1 parent d9d8ee5 commit 224045a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Python/hamt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ hamt_node_bitmap_assoc(PyHamtNode_Bitmap *self,
702702

703703
PyHamtNode_Bitmap *ret = hamt_node_bitmap_clone(self);
704704
if (ret == NULL) {
705+
Py_DECREF(sub_node);
705706
return NULL;
706707
}
707708
Py_SETREF(ret->b_array[val_idx], (PyObject*)sub_node);
@@ -994,6 +995,7 @@ hamt_node_bitmap_without(PyHamtNode_Bitmap *self,
994995

995996
PyHamtNode_Bitmap *clone = hamt_node_bitmap_clone(self);
996997
if (clone == NULL) {
998+
Py_DECREF(sub_node);
997999
return W_ERROR;
9981000
}
9991001

0 commit comments

Comments
 (0)