Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Unified Diff: src/runtime.cc

Issue 1795005: Fix search-for-string and replace global to avoid hangs... (Closed) Base URL: http://v8.googlecode.com/svn/branches/2.1/
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/search-string-multiple.js » ('j') | test/mjsunit/search-string-multiple.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 4511)
+++ src/runtime.cc (working copy)
@@ -3069,7 +3069,7 @@
StringSearchStrategy strategy =
InitializeStringSearch(pattern_string, is_ascii);
switch (strategy) {
- case SEARCH_FAIL: return false;
+ case SEARCH_FAIL: break;
case SEARCH_SHORT:
while (pos <= max_search_start) {
if (!builder->HasCapacity(kMaxBuilderEntriesPerRegExpMatch)) {
@@ -3096,16 +3096,17 @@
case SEARCH_LONG:
while (pos <= max_search_start) {
if (!builder->HasCapacity(kMaxBuilderEntriesPerRegExpMatch)) {
- *match_pos = pos;
- return false;
+ *match_pos = pos;
+ return false;
}
- int new_pos = ComplexIndexOf(subject,
- pattern_string,
- pos + pattern_length);
+ int match_end = pos + pattern_length;
+ int new_pos = ComplexIndexOf(subject, pattern_string, match_end);
if (new_pos >= 0) {
- // A match has been found.
- if (new_pos > pos) {
- ReplacementStringBuilder::AddSubjectSlice(builder, pos, new_pos);
+ // A match has been found.
+ if (new_pos > match_end) {
+ ReplacementStringBuilder::AddSubjectSlice(builder,
+ match_end,
+ new_pos);
}
pos = new_pos;
builder->Add(pattern);
« no previous file with comments | « no previous file | test/mjsunit/search-string-multiple.js » ('j') | test/mjsunit/search-string-multiple.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698