[cfe-dev] Constant C string fix

Chris Lattner clattner at apple.com
Tue Dec 9 11:11:17 PST 2008


On Dec 9, 2008, at 11:05 AM, David Chisnall wrote:

> The constant C string implementation in CodeGenModule is incorrect.
> When you do str + "\0", you are appending a C string to the string,
> and so it inserts all of the characters before the first NULL byte
> into the C++ string.  Since \0 is the first byte, (str + "\0") ==
> str.  This means anything calling GetAddrOfConstantCString() is
> getting the wrong result.  I found this due to the ObjC class lookup
> function being passed unterminated strings - it also explains the
> random crashes on Linux in the ObjC load function.  I haven't checked
> if this pattern is being used anywhere else.

Wow, scary.  Fixed here, thanks!
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20081208/010036.html

-Chirs



More information about the cfe-dev mailing list