Add comment.

llvm-svn: 84930
This commit is contained in:
Ted Kremenek 2009-10-23 04:45:31 +00:00
parent 0d670b5b92
commit ca42a51dce
1 changed files with 3 additions and 0 deletions

View File

@ -2515,6 +2515,9 @@ IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) {
// All of the strings in the PCH file are preceded by a 16-bit // All of the strings in the PCH file are preceded by a 16-bit
// length. Extract that 16-bit length to avoid having to execute // length. Extract that 16-bit length to avoid having to execute
// strlen(). // strlen().
// NOTE: 'StrLenPtr' is an 'unsigned char*' so that we load bytes as
// unsigned integers. This is important to avoid integer overflow when
// we cast them to 'unsigned'.
const unsigned char *StrLenPtr = (const unsigned char*) Str - 2; const unsigned char *StrLenPtr = (const unsigned char*) Str - 2;
unsigned StrLen = (((unsigned) StrLenPtr[0]) unsigned StrLen = (((unsigned) StrLenPtr[0])
| (((unsigned) StrLenPtr[1]) << 8)) - 1; | (((unsigned) StrLenPtr[1]) << 8)) - 1;