aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2010-06-18 01:01:56 +0000
committernyamatongwe <devnull@localhost>2010-06-18 01:01:56 +0000
commitd06051d3033a2ecffca877be796c04c004e739a5 (patch)
treea83536f94e871ba3a1e76a22677aebed3a5f5968
parenta8f2ba09fa60babe912dbc32c585083c9699d7a2 (diff)
downloadscintilla-mirror-d06051d3033a2ecffca877be796c04c004e739a5.tar.gz
Fix for bug #3017572 FindText crashes with empty text
Always return start position when search text is empty.
-rw-r--r--src/Document.cxx2
-rw-r--r--test/simpleTests.py4
2 files changed, 6 insertions, 0 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index 3c90d1f42..bc3ae0979 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -1151,6 +1151,8 @@ bool Document::MatchesWordOptions(bool word, bool wordStart, int pos, int length
long Document::FindText(int minPos, int maxPos, const char *search,
bool caseSensitive, bool word, bool wordStart, bool regExp, int flags,
int *length, CaseFolder *pcf) {
+ if (*length <= 0)
+ return minPos;
if (regExp) {
if (!regex)
regex = CreateRegexSearch(&charClass);
diff --git a/test/simpleTests.py b/test/simpleTests.py
index db414afea..e7e4b3671 100644
--- a/test/simpleTests.py
+++ b/test/simpleTests.py
@@ -748,6 +748,10 @@ class TestSearch(unittest.TestCase):
pos = self.ed.FindBytes(0, self.ed.Length, b"big", 0)
self.assertEquals(pos, 2)
+ def testFindEmpty(self):
+ pos = self.ed.FindBytes(0, self.ed.Length, b"", 0)
+ self.assertEquals(pos, 0)
+
def testCaseFind(self):
self.assertEquals(self.ed.FindBytes(0, self.ed.Length, b"big", 0), 2)
self.assertEquals(self.ed.FindBytes(0, self.ed.Length, b"bIg", 0), 2)