fix: postMessage crash with invalid transferrable (#46639)

This commit is contained in:
Shelley Vohr 2025-04-17 15:09:48 +02:00 committed by GitHub
parent e8117f8e40
commit 352a403efd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 82 additions and 31 deletions

View file

@ -10,6 +10,23 @@
namespace gin_helper {
bool IsValidWrappable(const v8::Local<v8::Value>& val,
const gin::WrapperInfo* wrapper_info) {
if (!val->IsObject())
return false;
v8::Local<v8::Object> port = val.As<v8::Object>();
if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
return false;
const gin::WrapperInfo* info = static_cast<gin::WrapperInfo*>(
port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
if (info != wrapper_info)
return false;
return true;
}
WrappableBase::WrappableBase() = default;
WrappableBase::~WrappableBase() {