This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bad assumption in gas/stabs.c?


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 (&notes, 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]