Index: src/regexp.js |
diff --git a/src/regexp.js b/src/regexp.js |
index a3675f033248ba59ffb983967e7951476b3b1e67..38090397aa21c037b6f2b047d947c026d7b3cf02 100644 |
--- a/src/regexp.js |
+++ b/src/regexp.js |
@@ -140,15 +140,18 @@ function BuildResultFromMatchInfo(lastMatchInfo, s) { |
var j = REGEXP_FIRST_CAPTURE + 2; |
for (var i = 1; i < numResults; i++) { |
start = lastMatchInfo[j++]; |
- if (start != -1) { |
- end = lastMatchInfo[j]; |
+ end = lastMatchInfo[j++]; |
+ if (end != -1) { |
if (start + 1 == end) { |
result[i] = %_StringCharAt(s, start); |
} else { |
result[i] = %_SubString(s, start, end); |
} |
+ } else { |
+ // Make sure the element is present. Avoid reading the undefined |
+ // property from the global object since this may change. |
+ result[i] = void 0; |
} |
- j++; |
} |
return result; |
} |