diff options
Diffstat (limited to 'src/Document.cxx')
-rw-r--r-- | src/Document.cxx | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 82f4c59bc..27363d6e9 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1052,12 +1052,13 @@ long Document::FindText(int minPos, int maxPos, const char *s, char firstChar = s[0]; if (!caseSensitive) firstChar = static_cast<char>(MakeUpperCase(firstChar)); - int pos = startPos; + int pos = forward ? startPos : (startPos - 1); while (forward ? (pos < endSearch) : (pos >= endSearch)) { char ch = CharAt(pos); if (caseSensitive) { if (ch == firstChar) { bool found = true; + if (pos + lengthFind > Platform::Maximum(startPos, endPos)) found = false; for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) { ch = CharAt(pos + posMatch); if (ch != s[posMatch]) @@ -1073,6 +1074,7 @@ long Document::FindText(int minPos, int maxPos, const char *s, } else { if (MakeUpperCase(ch) == firstChar) { bool found = true; + if (pos + lengthFind > Platform::Maximum(startPos, endPos)) found = false; for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) { ch = CharAt(pos + posMatch); if (MakeUpperCase(ch) != MakeUpperCase(s[posMatch])) |