This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/66528] [6 Regression] unbalanced IF/ENDIF with -fmax-errors=1 causes invalid free
- From: "tkoenig at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 17 Jun 2015 16:21:34 +0000
- Subject: [Bug fortran/66528] [6 Regression] unbalanced IF/ENDIF with -fmax-errors=1 causes invalid free
- Auto-submitted: auto-generated
- References: <bug-66528-4 at http dot gcc dot gnu dot org/bugzilla/>
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.