[3.15] gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179) (#150303)

gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179)
(cherry picked from commit 32823af153)

Co-authored-by: pengyu lee <lipengyu@kylinos.cn>
This commit is contained in:
Miss Islington (bot) 2026-05-23 21:27:27 +02:00 committed by GitHub
parent 6f99363150
commit 6b17d1a783
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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;
}