[Frontend] Don't index into an empty string.
Found by msan!
llvm-svn: 303686
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp
index a18b8c8..c43d9aa 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -1252,7 +1252,7 @@
}
// 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.