Skip to content

Commit f835552

Browse files
GH-141212: Fix possible memory leak in gc_mark_span_push (gh-141213)
1 parent 88953d5 commit f835552

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Python/gc_free_threading.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,11 @@ gc_mark_span_push(gc_span_stack_t *ss, PyObject **start, PyObject **end)
675675
else {
676676
ss->capacity *= 2;
677677
}
678-
ss->stack = (gc_span_t *)PyMem_Realloc(ss->stack, ss->capacity * sizeof(gc_span_t));
679-
if (ss->stack == NULL) {
678+
gc_span_t *new_stack = (gc_span_t *)PyMem_Realloc(ss->stack, ss->capacity * sizeof(gc_span_t));
679+
if (new_stack == NULL) {
680680
return -1;
681681
}
682+
ss->stack = new_stack;
682683
}
683684
assert(end > start);
684685
ss->stack[ss->size].start = start;

0 commit comments

Comments
 (0)