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( ...@@ -396,11 +396,14 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSValue(
isolate_, value, Execution::ToNumber(isolate_, object), EXCEPTION); isolate_, value, Execution::ToNumber(isolate_, object), EXCEPTION);
if (value->IsSmi()) return SerializeSmi(Smi::cast(*value)); if (value->IsSmi()) return SerializeSmi(Smi::cast(*value));
SerializeHeapNumber(Handle<HeapNumber>::cast(value)); SerializeHeapNumber(Handle<HeapNumber>::cast(value));
} else { } else if (class_name == isolate_->heap()->Boolean_string()) {
DCHECK(class_name == isolate_->heap()->Boolean_string());
Object* value = JSValue::cast(*object)->value(); Object* value = JSValue::cast(*object)->value();
DCHECK(value->IsBoolean()); DCHECK(value->IsBoolean());
builder_.AppendCString(value->IsTrue() ? "true" : "false"); builder_.AppendCString(value->IsTrue() ? "true" : "false");
} else {
// Fail gracefully for special value wrappers.
isolate_->ThrowIllegalOperation();
return EXCEPTION;
} }
return SUCCESS; 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