From 5f97f97f7c402d815c437e57ed749ed615530309 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:26:33 -0500 Subject: [PATCH] fix: confirm a `v8::Value` is a `v8::Object` before casting it (#43603) fix: confirm a v8::Value is a v8::Object before casting it Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- 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 a607349cbb4b..998376eed22e 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;