This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: bad assumption in gas/stabs.c?
- To: DJ Delorie <dj at redhat dot com>
- Subject: Re: bad assumption in gas/stabs.c?
- From: Nick Clifton <nickc at redhat dot com>
- Date: 15 Mar 2001 10:45:14 -0800
- Cc: binutils at sources dot redhat dot com
- References: <200103142300.SAA31162@greed.delorie.com>
Hi DJ,
> In s_stab_generic, we see code like this:
>
> string = demand_copy_C_string (&length);
> ...
> #ifdef md_flush_pending_output
> md_flush_pending_output ();
> #endif
> ...
> obstack_free (¬es, string);
>
> Now, in at least one case I saw, md_flush_pending_output called
> symbol_new(), which used the notes obstack to allocate something, and
> the obstack_free() freed more than just the string, which caused
> memory corruption, and eventually an abort.
>
> The documentation doesn't say md_flush_pending_output can't do that.
>
> The attached patch guards against this case, but is there some better
> solution?
Does the string actually need to be copied into an obstack ? It seems
to me that the same effect could be achieved simply by scanning to the
end of the string, temporarily replacing the closing " with a NUL and
then restoring it after the processing in s_stab_generic has finished.
The patch seems fine though, so if you prefer that solution, please go
ahead and apply it.
Cheers
Nick