| Index: src/string.js
|
| diff --git a/src/string.js b/src/string.js
|
| index 1a13d16428a2dbb961578b978566ff44edf49738..d8105fdfc0b88ffaa02a0e8ec110559a4c3b79a4 100644
|
| --- a/src/string.js
|
| +++ b/src/string.js
|
| @@ -332,6 +332,7 @@ function ApplyReplacementFunction(replace, captures, subject) {
|
| // ECMA-262 section 15.5.4.7
|
| %AddProperty($String.prototype, "indexOf", function(searchString /* position */) { // length == 1
|
| var str = ToString(this);
|
| + var str_len = str.length;
|
| var searchStr = ToString(searchString);
|
| var index = 0;
|
| if (%_ArgumentsLength() > 1) {
|
| @@ -339,8 +340,8 @@ function ApplyReplacementFunction(replace, captures, subject) {
|
| index = TO_INTEGER(arg1);
|
| }
|
| if (index < 0) index = 0;
|
| - if (index > str.length) index = str.length;
|
| - if (searchStr.length + index > str.length) return -1;
|
| + if (index > str_len) index = str_len;
|
| + if (searchStr.length + index > str_len) return -1;
|
| return %StringIndexOf(str, searchStr, index);
|
| }, DONT_ENUM);
|
|
|
|
|