Skip to content

Commit 5676bfc

Browse files
[3.14] gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179) (#150302)
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 86ffaf1 commit 5676bfc

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
@@ -701,6 +701,7 @@ hamt_node_bitmap_assoc(PyHamtNode_Bitmap *self,
701701

702702
PyHamtNode_Bitmap *ret = hamt_node_bitmap_clone(self);
703703
if (ret == NULL) {
704+
Py_DECREF(sub_node);
704705
return NULL;
705706
}
706707
Py_SETREF(ret->b_array[val_idx], (PyObject*)sub_node);
@@ -993,6 +994,7 @@ hamt_node_bitmap_without(PyHamtNode_Bitmap *self,
993994

994995
PyHamtNode_Bitmap *clone = hamt_node_bitmap_clone(self);
995996
if (clone == NULL) {
997+
Py_DECREF(sub_node);
996998
return W_ERROR;
997999
}
9981000

0 commit comments

Comments
 (0)