[Bug fortran/122491] [16 Regression] asan instrumented gcc: heap-use-after-free in fortran/parse.cc:1861 while running gfortran.dg/pr103508.f90
jvdelisle at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jan 18 04:21:55 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122491
--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #5)
> Perhaps
> if (state == COMP_BLOCK && !got_matching_end)
> {
> parent_ns = gfc_current_ns->parent;
>
> nsp = &(gfc_state_stack->previous->tail->ext.block.ns);
>
> prev_ns = NULL;
> ns = *nsp;
> while (ns)
> {
> if (ns == gfc_current_ns)
> {
> if (prev_ns == NULL)
> *nsp = NULL;
> else
> prev_ns->sibling = ns->sibling;
> }
> prev_ns = ns;
> ns = ns->sibling;
> }
>
> gfc_free_namespace (gfc_current_ns);
> gfc_current_ns = parent_ns;
> gfc_state_stack = gfc_state_stack->previous;
> state = gfc_current_state ();
> }
> shouldn't it instead of freeing the namespace just mark it for later
> gfc_free_namespace by parse_block_construct or parse_omp_structured_block?
An actual patch here would be helpful.
More information about the Gcc-bugs
mailing list