Skip to content

Commit 133bf61

Browse files
authored
Merge pull request #512 from chrisbckr/php8-v8js_to_zval_check_arraybuffer
Since ArrayBuffer has InternalFieldCount set to 2 by default, added !…
2 parents 21ed0f8 + 752cbdb commit 133bf61

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

v8js_convert.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ int v8js_to_zval(v8::Local<v8::Value> jsValue, zval *return_value, int flags, v8
260260
}
261261

262262
// if this is a wrapped PHP object, then just unwrap it.
263-
if (self->InternalFieldCount() == 2) {
263+
if ((self->InternalFieldCount() == 2) && !jsValue->IsArrayBufferView() && !jsValue->IsArrayBuffer()) {
264264
zend_object *object = reinterpret_cast<zend_object *>(self->GetAlignedPointerFromInternalField(1));
265265
zval zval_object;
266266
ZVAL_OBJ(&zval_object, object);

v8js_object_export.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, c
141141
{
142142
v8::Local<v8::Object> param_object;
143143

144-
if (info[i]->IsObject() && info[i]->ToObject(v8_context).ToLocal(&param_object) && param_object->InternalFieldCount() == 2)
144+
if (info[i]->IsObject() && info[i]->ToObject(v8_context).ToLocal(&param_object) && param_object->InternalFieldCount() == 2
145+
&& !param_object->IsArrayBufferView() && !param_object->IsArrayBuffer())
145146
{
146147
/* This is a PHP object, passed to JS and back. */
147148
zend_object *object = reinterpret_cast<zend_object *>(param_object->GetAlignedPointerFromInternalField(1));

v8js_v8.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ int v8js_get_properties_hash(v8::Local<v8::Value> jsValue, HashTable *retval, in
325325
ZVAL_UNDEF(&value);
326326

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

0 commit comments

Comments
 (0)