Skip to content

Commit

Permalink
fix: add IsExternal check to GetObjectClass
Browse files Browse the repository at this point in the history
  • Loading branch information
vadzz-dev committed Apr 12, 2024
1 parent 00d0e7f commit 5785c51
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion shared/V8Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,12 @@ V8Class::ObjectClass V8Helpers::GetObjectClass(v8::Local<v8::Object> obj)
{
if(obj->InternalFieldCount() <= static_cast<int>(V8Class::InternalFields::OBJECT_CLASS))
return V8Class::ObjectClass::NONE;

auto val = obj->GetInternalField(static_cast<int>(V8Class::InternalFields::OBJECT_CLASS));
if(!val->IsExternal())
return V8Class::ObjectClass::NONE;

void* cls = obj->GetInternalField(static_cast<int>(V8Class::InternalFields::OBJECT_CLASS)).As<v8::External>()->Value();
void* cls = val.As<v8::External>()->Value();
return *reinterpret_cast<V8Class::ObjectClass*>(&cls);
}

Expand Down

0 comments on commit 5785c51

Please sign in to comment.