aboutsummaryrefslogtreecommitdiff
path: root/strutil.cc
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2016-02-29 20:00:39 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2016-02-29 20:00:39 +0900
commit4a888024476b76f8ad7e10266ce179f0fc8af077 (patch)
tree004b44f32721e3518e1c7fd36af7ef707e96d0ee /strutil.cc
parent01406297a23201b3f99dfb316e7bb4e64b0472c3 (diff)
[C++] Honor string length in FindEndOfLine
When the character after the string is a backslash, FindOfLine returned a wrong length.
Diffstat (limited to 'strutil.cc')
-rw-r--r--strutil.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/strutil.cc b/strutil.cc
index 9d37052..d3c14d8 100644
--- a/strutil.cc
+++ b/strutil.cc
@@ -427,6 +427,10 @@ size_t FindEndOfLine(StringPiece s, size_t e, size_t* lf_cnt) {
static const char ranges[] = "\0\0\n\n\\\\";
while (e < s.size()) {
e += SkipUntilSSE42(s.data() + e, s.size() - e, ranges, 6);
+ if (e >= s.size()) {
+ CHECK(s.size() == e);
+ break;
+ }
char c = s[e];
if (c == '\0')
break;