fix: confirm a v8::Value is a v8::Object before casting it (#43601)

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 <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2024-09-06 14:18:26 -05:00 committed by GitHub
parent 37a7cb2c11
commit cf8a97a924
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -30,12 +30,12 @@ namespace electron {
namespace {
bool IsValidWrappable(const v8::Local<v8::Value>& obj) {
v8::Local<v8::Object> port = v8::Local<v8::Object>::Cast(obj);
if (!port->IsObject())
bool IsValidWrappable(const v8::Local<v8::Value>& val) {
if (!val->IsObject())
return false;
v8::Local<v8::Object> port = val.As<v8::Object>();
if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
return false;