Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Since ArrayBuffer has InternalFieldCount set to 2 by default, added !… #512

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion v8js_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ int v8js_to_zval(v8::Local<v8::Value> jsValue, zval *return_value, int flags, v8
}

// if this is a wrapped PHP object, then just unwrap it.
if (self->InternalFieldCount() == 2) {
if ((self->InternalFieldCount() == 2) && !jsValue->IsArrayBufferView() && !jsValue->IsArrayBuffer()) {
zend_object *object = reinterpret_cast<zend_object *>(self->GetAlignedPointerFromInternalField(1));
zval zval_object;
ZVAL_OBJ(&zval_object, object);
Expand Down
3 changes: 2 additions & 1 deletion v8js_object_export.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, c
{
v8::Local<v8::Object> param_object;

if (info[i]->IsObject() && info[i]->ToObject(v8_context).ToLocal(&param_object) && param_object->InternalFieldCount() == 2)
if (info[i]->IsObject() && info[i]->ToObject(v8_context).ToLocal(&param_object) && param_object->InternalFieldCount() == 2
&& !param_object->IsArrayBufferView() && !param_object->IsArrayBuffer())
{
/* This is a PHP object, passed to JS and back. */
zend_object *object = reinterpret_cast<zend_object *>(param_object->GetAlignedPointerFromInternalField(1));
Expand Down
3 changes: 2 additions & 1 deletion v8js_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ int v8js_get_properties_hash(v8::Local<v8::Value> jsValue, HashTable *retval, in
ZVAL_UNDEF(&value);

v8::Local<v8::Object> jsValObject;
if (jsVal->IsObject() && jsVal->ToObject(v8_context).ToLocal(&jsValObject) && jsValObject->InternalFieldCount() == 2) {
if (jsVal->IsObject() && !jsVal->IsArrayBufferView() && !jsVal->IsArrayBuffer()
&& jsVal->ToObject(v8_context).ToLocal(&jsValObject) && (jsValObject->InternalFieldCount() == 2)) {
/* This is a PHP object, passed to JS and back. */
zend_object *object = reinterpret_cast<zend_object *>(jsValObject->GetAlignedPointerFromInternalField(1));
ZVAL_OBJ(&value, object);
Expand Down