Revision: 11519
Author:   [email protected]
Date:     Mon May  7 06:23:56 2012
Log:      Fix crash bug in VisitChoice (bug=126272).
Review URL: https://chromiumcodereview.appspot.com/10332035
http://code.google.com/p/v8/source/detail?r=11519

Modified:
 /branches/bleeding_edge/src/jsregexp.cc
 /branches/bleeding_edge/test/mjsunit/regexp-capture-3.js

=======================================
--- /branches/bleeding_edge/src/jsregexp.cc     Thu May  3 01:22:12 2012
+++ /branches/bleeding_edge/src/jsregexp.cc     Mon May  7 06:23:56 2012
@@ -2722,8 +2722,8 @@
     GuardedAlternative alternative = alternatives_->at(i);
     RegExpNode* replacement = alternative.node()->FilterASCII(depth - 1);
     ASSERT(replacement != this);  // No missing EMPTY_MATCH_CHECK.
-    alternatives_->at(i).set_node(replacement);
     if (replacement != NULL) {
+      alternatives_->at(i).set_node(replacement);
       surviving++;
       survivor = replacement;
     }
@@ -2739,9 +2739,11 @@
   ZoneList<GuardedAlternative>* new_alternatives =
       new ZoneList<GuardedAlternative>(surviving);
   for (int i = 0; i < choice_count; i++) {
-    GuardedAlternative alternative = alternatives_->at(i);
-    if (alternative.node() != NULL) {
-      new_alternatives->Add(alternative);
+    RegExpNode* replacement =
+        alternatives_->at(i).node()->FilterASCII(depth - 1);
+    if (replacement != NULL) {
+      alternatives_->at(i).set_node(replacement);
+      new_alternatives->Add(alternatives_->at(i));
     }
   }
   alternatives_ = new_alternatives;
@@ -5832,7 +5834,12 @@
       node = loop_node;
     }
   }
-  if (is_ascii) node = node->FilterASCII(RegExpCompiler::kMaxRecursion);
+  if (is_ascii) {
+    node = node->FilterASCII(RegExpCompiler::kMaxRecursion);
+    // Do it again to propagate the new nodes to places where they were not
+    // put because they had not been calculated yet.
+ if (node != NULL) node = node->FilterASCII(RegExpCompiler::kMaxRecursion);
+  }

   if (node == NULL) node = new EndNode(EndNode::BACKTRACK);
   data->node = node;
=======================================
--- /branches/bleeding_edge/test/mjsunit/regexp-capture-3.js Thu May 3 01:22:12 2012 +++ /branches/bleeding_edge/test/mjsunit/regexp-capture-3.js Mon May 7 06:23:56 2012
@@ -212,3 +212,7 @@

 var regex10 = new RegExp(re, "i");
 regex10.exec(input0);
+
+var regex11 = /^(?:[^\u0000-\u0080]|[0-9a-z?,.!&\s#()])+$/i;
+regex11.exec(input0);
+

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

Reply via email to