Skip to content

Commit

Permalink
[Frontend] Don't index into an empty string.
Browse files Browse the repository at this point in the history
Found by msan!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303686 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
d0k committed May 23, 2017
1 parent 67b9708 commit 58d094a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Frontend/TextDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 58d094a

Please sign in to comment.