Skip to content

Commit

Permalink
Make nsFind::Find handle empty string searches.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfbeast committed May 25, 2019
1 parent 915ffc6 commit b89570e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions embedding/components/find/nsFind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b89570e

Please sign in to comment.