Commit 30034228 authored by Toon Verwaest's avatar Toon Verwaest Committed by V8 LUCI CQ

[json] Fix stringifier gap length above maxint

Change-Id: I296b7e2012bc8b1a141a382793b977e67ebf2a97
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3168343Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76940}
parent 5dde281c
......@@ -315,9 +315,9 @@ bool JsonStringifier::InitializeGap(Handle<Object> gap) {
gap_[gap_length] = '\0';
}
} else if (gap->IsNumber()) {
int num_value = DoubleToInt32(gap->Number());
if (num_value > 0) {
int gap_length = std::min(num_value, 10);
double value = std::min(gap->Number(), 10.0);
if (value > 0) {
int gap_length = DoubleToInt32(value);
gap_ = NewArray<base::uc16>(gap_length + 1);
for (int i = 0; i < gap_length; i++) gap_[i] = ' ';
gap_[gap_length] = '\0';
......
......@@ -523,3 +523,8 @@ assertEquals('{"":"inf"}', JSON.stringify({"":Infinity}, reviver));
assertEquals([10.4, "\u1234"], JSON.parse("[10.4, \"\u1234\"]"));
assertEquals(10, JSON.parse('{"10":10}')["10"]);
assertEquals(`[
1,
2
]`, JSON.stringify([1,2], undefined, 1000000000000000));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment