mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1240500 - Early return on empty pattern to avoid an infinte loop and OOM r=rnewman
MozReview-Commit-ID: 7GlsZjfmE0y
This commit is contained in:
parent
d5efa2bb5f
commit
9136800123
@ -25,6 +25,7 @@ import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.Typeface;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@ -170,7 +171,15 @@ class SearchEngineRow extends AnimatedHeightLayout {
|
||||
*/
|
||||
private void refreshOccurrencesWith(String pattern, String string) {
|
||||
mOccurrences.clear();
|
||||
|
||||
// Don't try to search for an empty string - String.indexOf will return 0, which would result
|
||||
// in us iterating with lastIndexOfMatch = 0, which eventually results in an OOM.
|
||||
if (TextUtils.isEmpty(pattern)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int patternLength = pattern.length();
|
||||
|
||||
int indexOfMatch = 0;
|
||||
int lastIndexOfMatch = 0;
|
||||
while(indexOfMatch != -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user