https://github.com/python/cpython/commit/f835552946e29ec20144c359b8822f9e421d4d64
commit: f835552946e29ec20144c359b8822f9e421d4d64
branch: main
author: Sergey Miryanov <[email protected]>
committer: colesbury <[email protected]>
date: 2025-11-10T11:19:13-05:00
summary:

GH-141212: Fix possible memory leak in gc_mark_span_push (gh-141213)

files:
M Python/gc_free_threading.c

diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c
index f39793c3eeb532..b183062eff7952 100644
--- a/Python/gc_free_threading.c
+++ b/Python/gc_free_threading.c
@@ -675,10 +675,11 @@ gc_mark_span_push(gc_span_stack_t *ss, PyObject **start, 
PyObject **end)
         else {
             ss->capacity *= 2;
         }
-        ss->stack = (gc_span_t *)PyMem_Realloc(ss->stack, ss->capacity * 
sizeof(gc_span_t));
-        if (ss->stack == NULL) {
+        gc_span_t *new_stack = (gc_span_t *)PyMem_Realloc(ss->stack, 
ss->capacity * sizeof(gc_span_t));
+        if (new_stack == NULL) {
             return -1;
         }
+        ss->stack = new_stack;
     }
     assert(end > start);
     ss->stack[ss->size].start = start;

_______________________________________________
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