This is the mail archive of the
mailing list for the GCC project.
Re: [patch] fix memory corruption in libcpp (pr 19077)
On Tue, 2005-02-15 at 11:56 -0800, Zack Weinberg wrote:
> Eric Christopher <firstname.lastname@example.org> writes:
> > I took a look at this with valgrind after glibc told me that we were
> > corrupting the malloc data structures. After some looking I realized
> > that the length calculation was missing one condition that we used in
> > writing to the array. This fixes the memory corruption problem and the
> > testcase compiles just fine.
> > + if (token->flags & PREV_WHITE)
> > + len++; /* " " */
> This was supposed to be handled by the
> len += cpp_token_len (token) + 1; /* Includes room for ' '. */
> a couple lines above. I see that this neglects to handle
> CPP_MACRO_ARG tokens with preceding whitespace. So your fix is
> correct, but incomplete. Would you please take out that +1 and
> comment, and retest?
Sure. Will do.