summaryrefslogtreecommitdiffstats
path: root/embedding/components/find
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-05-25 15:07:51 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-05-25 15:07:51 +0200
commitb89570e31cfb84449241e363a595540b8810c217 (patch)
treea2be1d5d66e0131649768a2a3448fa4a28c268c9 /embedding/components/find
parent915ffc660053cc48153c00dec66b913517dba794 (diff)
downloadUXP-b89570e31cfb84449241e363a595540b8810c217.tar
UXP-b89570e31cfb84449241e363a595540b8810c217.tar.gz
UXP-b89570e31cfb84449241e363a595540b8810c217.tar.lz
UXP-b89570e31cfb84449241e363a595540b8810c217.tar.xz
UXP-b89570e31cfb84449241e363a595540b8810c217.zip
Make nsFind::Find handle empty string searches.
Diffstat (limited to 'embedding/components/find')
-rw-r--r--embedding/components/find/nsFind.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/embedding/components/find/nsFind.cpp b/embedding/components/find/nsFind.cpp
index 5fc1f9db6..6987c11d3 100644
--- a/embedding/components/find/nsFind.cpp
+++ b/embedding/components/find/nsFind.cpp
@@ -966,6 +966,11 @@ nsFind::Find(const char16_t* aPatText, nsIDOMRange* aSearchRange,
const char16_t* patStr = patAutoStr.get();
int32_t patLen = patAutoStr.Length() - 1;
+
+ // If this function is called with an empty string, we should early exit.
+ if (patLen < 0) {
+ return NS_OK;
+ }
// current offset into the pattern -- reset to beginning/end:
int32_t pindex = (mFindBackward ? patLen : 0);