Reviewers: Mads Ager,

Description:
Port 5615 to 2.3 branch. Fixes issue 58740.

Please review this at http://codereview.chromium.org/3746005/show

Affected files:
  M src/regexp.js
  M src/version.cc
  A test/mjsunit/regress/regress-58740.js


Index: src/regexp.js
diff --git a/src/regexp.js b/src/regexp.js
index faa525d62da27ca518e3b4fa8ec12f6ab2cbdaa8..59c40407fbc20ddc4406d0ef2661d7d9bcf39099 100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -186,10 +186,10 @@ function RegExpExec(string) {
       %_IsRegExpEquivalent(cache.regExp, this) &&
       %_ObjectEquals(cache.subject, string)) {
     if (cache.answerSaved) {
- // If this regexp is not global, cache.lastIndex is zero, so we only get
+      // If this regexp is global, cache.lastIndex is zero, so we only get
       // here if this.lastIndex is zero, and resulting this.lastIndex
       // must be zero too, so no change is necessary.
-      if (this.global) this.lastIndex = lastMatchInfo[CAPTURE1];
+      if (!this.global) this.lastIndex = lastMatchInfo[CAPTURE1];
       return %_RegExpCloneResult(cache.answer);
     } else {
       saveAnswer = true;
Index: src/version.cc
diff --git a/src/version.cc b/src/version.cc
index ba4ce536b25dee9fed7916f38fe1de2a64c985ab..4f4d1fad01d2663748ecee7ba4751f91c9844543 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     2
 #define MINOR_VERSION     3
 #define BUILD_NUMBER      11
-#define PATCH_LEVEL       17
+#define PATCH_LEVEL       18
 #define CANDIDATE_VERSION false

 // Define SONAME to have the SCons build the put a specific SONAME into the
Index: test/mjsunit/regress/regress-58740.js
diff --git a/test/mjsunit/regress/regress-58740.js b/test/mjsunit/regress/regress-58740.js
new file mode 100644
index 0000000000000000000000000000000000000000..ab3e93b53e35e56affc7997cf482c88b5b5316ab
--- /dev/null
+++ b/test/mjsunit/regress/regress-58740.js
@@ -0,0 +1,35 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// See: http://code.google.com/p/chromium/issues/detail?id=58740
+
+var re = /.+/g;
+re.exec("");
+re.exec("anystring");
+re=/.+/g;
+re.exec("");
+assertEquals(0, re.lastIndex);


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to