diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-05-25 15:07:51 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-05-25 22:15:02 +0200 |
commit | 1692f52a5337c21c276ac1e54bbacc2b35ac4bbc (patch) | |
tree | 4aeb0db850dce0c8dbbb8487abed8ffd87745c72 /embedding/components/find | |
parent | 7258eeb1f5c1fdc43e6351cead4a039343c47f1a (diff) | |
download | UXP-1692f52a5337c21c276ac1e54bbacc2b35ac4bbc.tar UXP-1692f52a5337c21c276ac1e54bbacc2b35ac4bbc.tar.gz UXP-1692f52a5337c21c276ac1e54bbacc2b35ac4bbc.tar.lz UXP-1692f52a5337c21c276ac1e54bbacc2b35ac4bbc.tar.xz UXP-1692f52a5337c21c276ac1e54bbacc2b35ac4bbc.zip |
Make nsFind::Find handle empty string searches.
Diffstat (limited to 'embedding/components/find')
-rw-r--r-- | embedding/components/find/nsFind.cpp | 5 |
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); |