Skip to content

Commit

Permalink
don't deref NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner committed Jul 3, 2024
1 parent 700c2fd commit cde931d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Python/gc_free_threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,11 @@ gc_visit_thread_stacks(PyInterpreterState *interp)
_PyInterpreterFrame *curr_frame = p->current_frame;
while (curr_frame != NULL) {
PyCodeObject *co = (PyCodeObject *)curr_frame->f_executable;
for (int i = 0; i < co->co_nlocalsplus + co->co_stacksize; i++) {
gc_visit_stackref(curr_frame->localsplus[i]);
if (co != NULL && PyCode_Check(co)) {
for (int i = 0;
i < co->co_nlocalsplus + co->co_stacksize; i++) {
gc_visit_stackref(curr_frame->localsplus[i]);
}
}
curr_frame = curr_frame->previous;
}
Expand Down Expand Up @@ -585,14 +588,14 @@ deduce_unreachable_heap(PyInterpreterState *interp,
// incoming references.
gc_visit_heaps(interp, &update_refs, &state->base);

gc_visit_thread_stacks(interp);

#ifdef GC_DEBUG
// Check that all objects are marked as unreachable and that the computed
// reference count difference (stored in `ob_tid`) is non-negative.
gc_visit_heaps(interp, &validate_gc_objects, &state->base);
#endif

gc_visit_thread_stacks(interp);

// Transitively mark reachable objects by clearing the
// _PyGC_BITS_UNREACHABLE flag.
if (gc_visit_heaps(interp, &mark_heap_visitor, &state->base) < 0) {
Expand Down

0 comments on commit cde931d

Please sign in to comment.