From 95c93239be9d6e7f047ab3fba41b6bff3e9aca0c Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sat, 23 May 2026 11:24:11 +0200 Subject: [PATCH] [3.13] gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179) (#150301) gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179) (cherry picked from commit 32823af153b76b7042fbce28ea8a6e0c3c4f1ca8) Co-authored-by: pengyu lee --- Python/hamt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/hamt.c b/Python/hamt.c index a9f811f4422..98c8cc3192a 100644 --- a/Python/hamt.c +++ b/Python/hamt.c @@ -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; }