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

Unified Diff: src/jsregexp.cc

Issue 2858033: Fix Chromium issue 47824. (Closed)
Patch Set: Addressed review comments Created 10 years, 6 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 | « src/handles.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/jsregexp.cc
diff --git a/src/jsregexp.cc b/src/jsregexp.cc
index 3e9c5eab9a51a3a8595106c795b73fbd8825b662..9f98782bbc19a375fec4a903040711a7b19b3760 100644
--- a/src/jsregexp.cc
+++ b/src/jsregexp.cc
@@ -356,7 +356,16 @@ int RegExpImpl::IrregexpPrepare(Handle<JSRegExp> regexp,
if (!subject->IsFlat()) {
FlattenString(subject);
}
- bool is_ascii = subject->IsAsciiRepresentation();
+ // Check the asciiness of the underlying storage.
+ bool is_ascii;
+ {
+ AssertNoAllocation no_gc;
+ String* sequential_string = *subject;
+ if (subject->IsConsString()) {
+ sequential_string = ConsString::cast(*subject)->first();
+ }
+ is_ascii = sequential_string->IsAsciiRepresentation();
+ }
if (!EnsureCompiledIrregexp(regexp, is_ascii)) {
return -1;
}
@@ -381,6 +390,11 @@ RegExpImpl::IrregexpResult RegExpImpl::IrregexpExecOnce(Handle<JSRegExp> regexp,
ASSERT(index <= subject->length());
ASSERT(subject->IsFlat());
+ // A flat ASCII string might have a two-byte first part.
+ if (subject->IsConsString()) {
+ subject = Handle<String>(ConsString::cast(*subject)->first());
+ }
+
#ifndef V8_INTERPRETED_REGEXP
ASSERT(output.length() >=
(IrregexpNumberOfCaptures(*irregexp) + 1) * 2);
@@ -407,7 +421,7 @@ RegExpImpl::IrregexpResult RegExpImpl::IrregexpExecOnce(Handle<JSRegExp> regexp,
// If result is RETRY, the string has changed representation, and we
// must restart from scratch.
// In this case, it means we must make sure we are prepared to handle
- // the, potentially, differen subject (the string can switch between
+ // the, potentially, different subject (the string can switch between
// being internal and external, and even between being ASCII and UC16,
// but the characters are always the same).
IrregexpPrepare(regexp, subject);
« no previous file with comments | « src/handles.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698