r295820 - [ODRHash] Avoid dereferencing end() of a SmallVector.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 22 02:19:45 PST 2017


Author: d0k
Date: Wed Feb 22 04:19:45 2017
New Revision: 295820

URL: http://llvm.org/viewvc/llvm-project?rev=295820&view=rev
Log:
[ODRHash] Avoid dereferencing end() of a SmallVector.

Found by MSAN.

Modified:
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=295820&r1=295819&r2=295820&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Feb 22 04:19:45 2017
@@ -8987,7 +8987,8 @@ void ASTReader::diagnoseOdrViolations()
       // SecondDiffType will not be Other and FirstDecl and SecondDecl will be
       // filled in if not EndOfClass.
       while (FirstIt != FirstHashes.end() || SecondIt != SecondHashes.end()) {
-        if (FirstIt->second == SecondIt->second) {
+        if (FirstIt != FirstHashes.end() && SecondIt != SecondHashes.end() &&
+            FirstIt->second == SecondIt->second) {
           ++FirstIt;
           ++SecondIt;
           continue;




More information about the cfe-commits mailing list