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

Unified Diff: src/json-stringifier.h

Issue 1997003002: [json] fix encoding change for two-byte gap strings. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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/regress/regress-crbug-613570.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/json-stringifier.h
diff --git a/src/json-stringifier.h b/src/json-stringifier.h
index 05f4231f41ca62869049e7a708f35e0580953f87..8d53369f6ae3f75763ffc9b4e9cd10184d1fe55c 100644
--- a/src/json-stringifier.h
+++ b/src/json-stringifier.h
@@ -198,7 +198,8 @@ BasicJsonStringifier::BasicJsonStringifier(Isolate* isolate, Handle<String> gap)
stack_ = factory()->NewJSArray(8);
int gap_length = gap->length();
if (gap_length != 0) {
- String::Flatten(gap);
+ gap = String::Flatten(gap);
+ if (gap->IsTwoByteRepresentation()) builder_.ChangeEncoding();
DisallowHeapAllocation no_gc;
String::FlatContent flat = gap->GetFlatContent();
gap_ = NewArray<uc16>(gap_length + 1);
@@ -206,7 +207,6 @@ BasicJsonStringifier::BasicJsonStringifier(Isolate* isolate, Handle<String> gap)
CopyChars(gap_, flat.ToOneByteVector().start(), gap_length);
} else {
CopyChars(gap_, flat.ToUC16Vector().start(), gap_length);
- builder_.ChangeEncoding();
}
gap_[gap_length] = '\0';
} else {
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-613570.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698