r303686 - [Frontend] Don't index into an empty string.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Tue May 23 13:48:21 PDT 2017
Author: d0k
Date: Tue May 23 15:48:21 2017
New Revision: 303686
URL: http://llvm.org/viewvc/llvm-project?rev=303686&view=rev
Log:
[Frontend] Don't index into an empty string.
Found by msan!
Modified:
cfe/trunk/lib/Frontend/TextDiagnostic.cpp
Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=303686&r1=303685&r2=303686&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Tue May 23 15:48:21 2017
@@ -1252,7 +1252,7 @@ void TextDiagnostic::emitSnippetAndCaret
}
// Finally, remove any blank spaces from the end of CaretLine.
- while (CaretLine[CaretLine.size() - 1] == ' ')
+ while (!CaretLine.empty() && CaretLine[CaretLine.size() - 1] == ' ')
CaretLine.erase(CaretLine.end() - 1);
// Emit what we have computed.
More information about the cfe-commits
mailing list