Commit 48eaa749 authored by Vicky Kontoura's avatar Vicky Kontoura Committed by V8 LUCI CQ

[web snapshot] Improve error handling in Realm.useWebSnapshot()

Bug: v8:11525, v8:11706
Change-Id: Ia1f15ab33708831323bed5cdd9b8d3cf029cb7a1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2928183Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Vicky Kontoura <vkont@google.com>
Cr-Commit-Position: refs/heads/master@{#74863}
parent c211cb43
......@@ -1876,7 +1876,7 @@ void Shell::RealmTakeWebSnapshot(
void Shell::RealmUseWebSnapshot(
const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
if (args.Length() < 2) {
if (args.Length() < 2 || !args[1]->IsObject()) {
isolate->ThrowError("Invalid argument");
return;
}
......@@ -1885,7 +1885,8 @@ void Shell::RealmUseWebSnapshot(
if (index == -1) return;
// Restore the snapshot data from the snapshot object.
Local<Object> snapshot_instance = args[1].As<Object>();
if (snapshot_instance->InternalFieldCount() != 1) {
Local<FunctionTemplate> snapshot_template = data->GetSnapshotObjectCtor();
if (!snapshot_template->HasInstance(snapshot_instance)) {
isolate->ThrowError("Invalid argument");
return;
}
......
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