From 3605fcbe63c22ac61f7aafbe40c73cc0c823cb58 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Mon, 13 Aug 2012 15:53:40 +0000 Subject: [PATCH] Fix indexing bug in regexp, part 2. The previous fix initialized the start index incorrectly. BUG= Review URL: https://chromiumcodereview.appspot.com/10834291 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12302 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/jsregexp.cc | 4 ++-- test/mjsunit/regress/regress-crbug-142087.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jsregexp.cc b/src/jsregexp.cc index 0bca6a997d..ae25432a58 100644 --- a/src/jsregexp.cc +++ b/src/jsregexp.cc @@ -748,12 +748,12 @@ RegExpImpl::GlobalCache::GlobalCache(Handle regexp, // Set state so that fetching the results the first time triggers a call // to the compiled regexp. - current_match_index_ = max_matches_; + current_match_index_ = max_matches_ - 1; num_matches_ = max_matches_; ASSERT(registers_per_match_ >= 2); // Each match has at least one capture. ASSERT_GE(register_array_size_, registers_per_match_); int32_t* last_match = - ®ister_array_[(current_match_index_ - 1) * registers_per_match_]; + ®ister_array_[current_match_index_ * registers_per_match_]; last_match[0] = -1; last_match[1] = 0; } diff --git a/test/mjsunit/regress/regress-crbug-142087.js b/test/mjsunit/regress/regress-crbug-142087.js index 6a1dbf7b86..881ca60fba 100644 --- a/test/mjsunit/regress/regress-crbug-142087.js +++ b/test/mjsunit/regress/regress-crbug-142087.js @@ -27,7 +27,7 @@ var string = "What are you looking for?"; -var expected_match = []; +var expected_match = [""]; for (var i = 0; i < string.length; i++) { expected_match.push(""); }