[cfe-commits] r90703 - /cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
Daniel Dunbar
daniel at zuster.org
Sun Dec 6 01:56:18 PST 2009
Author: ddunbar
Date: Sun Dec 6 03:56:18 2009
New Revision: 90703
URL: http://llvm.org/viewvc/llvm-project?rev=90703&view=rev
Log:
Fix an off by one in findEndOfWord, which could scan past the end of the string in a corner case.
Modified:
cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=90703&r1=90702&r2=90703&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Sun Dec 6 03:56:18 2009
@@ -497,12 +497,17 @@
///
/// \returns the index pointing one character past the end of the
/// word.
-unsigned findEndOfWord(unsigned Start,
- const llvm::SmallVectorImpl<char> &Str,
- unsigned Length, unsigned Column,
- unsigned Columns) {
+static unsigned findEndOfWord(unsigned Start,
+ const llvm::SmallVectorImpl<char> &Str,
+ unsigned Length, unsigned Column,
+ unsigned Columns) {
+ assert(Start < Str.size() && "Invalid start position!");
unsigned End = Start + 1;
+ // If we are already at the end of the string, take that as the word.
+ if (End == Str.size())
+ return End;
+
// Determine if the start of the string is actually opening
// punctuation, e.g., a quote or parentheses.
char EndPunct = findMatchingPunctuation(Str[Start]);
More information about the cfe-commits
mailing list