Fix for off-by-one error in cpplib
Mon Mar 13 09:08:00 GMT 2000
>>>>> grahams writes:
Graham> Andreas, Zack, ...
Graham> Andreas Jaeger wrote:
Graham> Whoops we are now putting the '\0' in the wrong place
Graham> (i.e past the end of the allocated buffer)
Oh no, not again a broken patch by me for this wee problem :-(.
Graham> I think the following does the correct thing!
>> name = pfile->token_buffer + written + 1;
>> len = strlen (name);
>> - copy = (U_CHAR *) alloca (len);
>> + copy = (U_CHAR *) alloca (len + 1)
>> - memcpy (copy, name, len - 1);
>> + memcpy (copy, name, len);
>> copy[len] = '\0'; /* trim trailing quote */
Looks ok to me.
Thanks a lot,
SuSE Labs firstname.lastname@example.org
More information about the Gcc-patches