[Bug fortran/66528] [6 Regression] unbalanced IF/ENDIF with -fmax-errors=1 causes invalid free
tkoenig at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 17 16:21:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66528
--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #4)
> diagnostic_finish tries to free the output_buffer,
> but the error_buffer is statically allocated. I think this should be enough:
>
> --- error.c (revision 223651)
> +++ error.c (working copy)
> @@ -1379,12 +1379,12 @@ gfc_error_check (void)
> output_buffer *tmp_buffer = pp->buffer;
> pp->buffer = pp_error_buffer;
> pp_really_flush (pp);
> ++errorcount;
> gcc_assert (gfc_output_buffer_empty_p (pp_error_buffer));
> - diagnostic_action_after_output (global_dc, DK_ERROR);
> pp->buffer = tmp_buffer;
> + diagnostic_action_after_output (global_dc, DK_ERROR);
> return true;
> }
>
> return false;
> }
>
> However, a better fix may be to make the error_buffer also dynamically
> allocated like the warning_buffer. Not sure why I did the change.
I think either version would be OK, but I agree that making
the error_buffer dynamic would be better.
> (It would be nice to have a testcase testing this in the regression
> testsuite.)
Easy enough to generate from the test case in comment #2.
More information about the Gcc-bugs
mailing list