Skip to content

Commit b597480

Browse files
fix: Ensure Environment::get_verified_object actually called verify_object
Addresses a class of error that can be encountered when an object belongs to a different Environment.
1 parent b936117 commit b597480

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

bridge/jsb_environment.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -883,13 +883,14 @@ namespace jsb
883883
JSB_LOG(Error, "duplicate adding persistent object: %d", (uintptr_t) p_pointer);
884884
}
885885

886-
void* Environment::get_verified_object(const v8::Local<v8::Object>& p_obj, NativeClassType::Type p_type) const
886+
void* Environment::get_verified_object(const v8::Local<v8::Object>& p_obj, NativeClassType::Type p_type) const
887887
{
888-
if (!TypeConvert::is_object(p_obj, p_type))
889-
{
890-
return nullptr;
891-
}
892-
return p_obj->GetAlignedPointerFromInternalField(IF_Pointer);
888+
if (!TypeConvert::is_object(p_obj, p_type))
889+
{
890+
return nullptr;
891+
}
892+
void* pointer = p_obj->GetAlignedPointerFromInternalField(IF_Pointer);
893+
return verify_object(pointer) ? pointer : nullptr;
893894
}
894895

895896
bool Environment::reference_object(void* p_pointer, bool p_is_inc)

0 commit comments

Comments
 (0)