From fe0d4274e23663e2047cac8f18b3940142ad9cda Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 6 Sep 2024 11:20:04 -0500 Subject: [PATCH] fix: confirm a `v8::Value` is a `v8::Object` before casting it (#43575) fix: confirm a v8::Value is a v8::Object before casting it --- shell/browser/api/message_port.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc index d30866c1ed..f531f05217 100644 --- a/shell/browser/api/message_port.cc +++ b/shell/browser/api/message_port.cc @@ -30,12 +30,12 @@ namespace electron { namespace { -bool IsValidWrappable(const v8::Local& obj) { - v8::Local port = v8::Local::Cast(obj); - - if (!port->IsObject()) +bool IsValidWrappable(const v8::Local& val) { + if (!val->IsObject()) return false; + v8::Local port = val.As(); + if (port->InternalFieldCount() != gin::kNumberOfInternalFields) return false;