[Frontend] Don't index into an empty string.

Found by msan!

llvm-svn: 303686
This commit is contained in:
Benjamin Kramer 2017-05-23 20:48:21 +00:00
parent f43ece3ff5
commit 4e382f9ee9
1 changed files with 1 additions and 1 deletions

View File

@ -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.