summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-10-23 04:45:31 +0000
committerTed Kremenek <kremenek@apple.com>2009-10-23 04:45:31 +0000
commitca42a51dcefc9671f5aad416c6e92d4f545336d7 (patch)
tree75f8f2676029df60cd1222080b9cc57d2d6166e0
parent0d670b5b92fc7bdd4e57473712b54a3bf7460e86 (diff)
downloadbcm5719-llvm-ca42a51dcefc9671f5aad416c6e92d4f545336d7.tar.gz
bcm5719-llvm-ca42a51dcefc9671f5aad416c6e92d4f545336d7.zip
Add comment.
llvm-svn: 84930
-rw-r--r--clang/lib/Frontend/PCHReader.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp
index d4302f44c8b..9c6059b1c7c 100644
--- a/clang/lib/Frontend/PCHReader.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud