Commit 7681432d authored by yangguo's avatar yangguo Committed by Commit bot

JSON serializer should fail gracefully for special value wrappers.

R=mstarzinger@chromium.org
BUG=chromium:471702
LOG=N

Review URL: https://codereview.chromium.org/1120573002

Cr-Commit-Position: refs/heads/master@{#28154}
parent b9d583d5
......@@ -396,11 +396,14 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSValue(
isolate_, value, Execution::ToNumber(isolate_, object), EXCEPTION);
if (value->IsSmi()) return SerializeSmi(Smi::cast(*value));
SerializeHeapNumber(Handle<HeapNumber>::cast(value));
} else {
DCHECK(class_name == isolate_->heap()->Boolean_string());
} else if (class_name == isolate_->heap()->Boolean_string()) {
Object* value = JSValue::cast(*object)->value();
DCHECK(value->IsBoolean());
builder_.AppendCString(value->IsTrue() ? "true" : "false");
} else {
// Fail gracefully for special value wrappers.
isolate_->ThrowIllegalOperation();
return EXCEPTION;
}
return SUCCESS;
}
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
assertThrows(function() { JSON.stringify(%DebugGetLoadedScripts()); });
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