fix: postMessage crash with invalid transferrable (#46666)

* fix: postMessage crash with invalid transferrable

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: address review feedback

Co-authored-by: Charles Kerr <charles@charleskerr.com>

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2025-04-17 18:23:26 +02:00 committed by GitHub
parent ee04cb9ebe
commit 0675686451
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() {

View file

@ -11,6 +11,9 @@
namespace gin_helper {
bool IsValidWrappable(const v8::Local<v8::Value>& obj,
const gin::WrapperInfo* wrapper_info);
namespace internal {
void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val);