]> granicus.if.org Git - clang/commitdiff
Add comment.
authorTed Kremenek <kremenek@apple.com>
Fri, 23 Oct 2009 04:45:31 +0000 (04:45 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 23 Oct 2009 04:45:31 +0000 (04:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84930 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PCHReader.cpp

index d4302f44c8b70d3f57757e4278f1637d4462d305..9c6059b1c7c01c8b9485da7b07ef5118ecc8b4d4 100644 (file)
@@ -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;