https://github.com/python/cpython/commit/5676bfcf859529b9ddd9a74b3199f2d932992458
commit: 5676bfcf859529b9ddd9a74b3199f2d932992458
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-05-24T07:42:21Z
summary:

[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 32823af153b76b7042fbce28ea8a6e0c3c4f1ca8)

Co-authored-by: pengyu lee <[email protected]>

files:
M Python/hamt.c

diff --git a/Python/hamt.c b/Python/hamt.c
index 881290a0e60db87..98ef96df2c54e37 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -701,6 +701,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);
@@ -993,6 +994,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;
                 }
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to