[cfe-commits] r84930 - /cfe/trunk/lib/Frontend/PCHReader.cpp

Ted Kremenek kremenek at apple.com
Thu Oct 22 21:45:32 PDT 2009


Author: kremenek
Date: Thu Oct 22 23:45:31 2009
New Revision: 84930

URL: http://llvm.org/viewvc/llvm-project?rev=84930&view=rev
Log:
Add comment.

Modified:
    cfe/trunk/lib/Frontend/PCHReader.cpp

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=84930&r1=84929&r2=84930&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Thu Oct 22 23:45:31 2009
@@ -2515,6 +2515,9 @@
     // 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;





More information about the cfe-commits mailing list