From 58d094a82f7eaa8fc70d6c866fcc9403aa39ad4a Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 23 May 2017 20:48:21 +0000 Subject: [PATCH] [Frontend] Don't index into an empty string. Found by msan! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303686 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/TextDiagnostic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp index a18b8c888c..c43d9aa98d 100644 --- a/lib/Frontend/TextDiagnostic.cpp +++ b/lib/Frontend/TextDiagnostic.cpp @@ -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. -- 2.40.0