Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: src/string.js

Issue 2987: Don't try an indexOf() when the search string is bigger than the string. (Closed)
Patch Set: Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index da9ba6acb89893d0e7f070359f10912db5db5f47..1a13d16428a2dbb961578b978566ff44edf49738 100644
--- a/src/string.js
+++ b/src/string.js
@@ -340,6 +340,7 @@ function ApplyReplacementFunction(replace, captures, subject) {
}
if (index < 0) index = 0;
if (index > str.length) index = str.length;
+ if (searchStr.length + index > str.length) return -1;
return %StringIndexOf(str, searchStr, index);
}, DONT_ENUM);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698