From: Ted Kremenek Date: Fri, 23 Oct 2009 04:45:31 +0000 (+0000) Subject: Add comment. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=231bc0b7a7f53ce0d1af85602232486bc92c5a34;p=clang Add comment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84930 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index d4302f44c8..9c6059b1c7 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -2515,6 +2515,9 @@ IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) { // 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 // 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; unsigned StrLen = (((unsigned) StrLenPtr[0]) | (((unsigned) StrLenPtr[1]) << 8)) - 1;