Skip to content

Commit 9f42519

Browse files
[3.14] GH-141212: Fix possible memory leak in gc_mark_span_push (gh-141213) (gh-141364)
(cherry picked from commit f835552) Co-authored-by: Sergey Miryanov <[email protected]>
1 parent 63a3737 commit 9f42519

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)