Skip to content

Commit c4c5a19

Browse files
committed
fix wrapped php object detection, closes #240
V8 since 5.3.337 returns InternalFieldCount() == -1 for special objects like "arguments", which fulfilled the old check.
1 parent 7b6f133 commit c4c5a19

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

v8js_convert.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ int v8js_to_zval(v8::Handle<v8::Value> jsValue, zval *return_value, int flags, v
240240
v8::Local<v8::Object> self = jsValue->ToObject();
241241

242242
// if this is a wrapped PHP object, then just unwrap it.
243-
if (self->InternalFieldCount()) {
243+
if (self->InternalFieldCount() == 2) {
244244
zval *object = reinterpret_cast<zval *>(self->GetAlignedPointerFromInternalField(1));
245245
RETVAL_ZVAL(object, 1, 0);
246246
return SUCCESS;

v8js_exceptions.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::
8383
PHPV8_EXPROP(_string, JsTrace, stacktrace_string);
8484
}
8585

86-
if(try_catch->Exception()->IsObject() && try_catch->Exception()->ToObject()->InternalFieldCount()) {
86+
if(try_catch->Exception()->IsObject() && try_catch->Exception()->ToObject()->InternalFieldCount() == 2) {
8787
zval *php_exception = reinterpret_cast<zval *>(try_catch->Exception()->ToObject()->GetAlignedPointerFromInternalField(1));
8888

8989
zend_class_entry *exception_ce = zend_exception_get_default(TSRMLS_C);

v8js_object_export.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static void v8js_call_php_func(zval *value, zend_class_entry *ce, zend_function
8989
fci.params = (zval ***) safe_emalloc(argc, sizeof(zval **), 0);
9090
argv = (zval **) safe_emalloc(argc, sizeof(zval *), 0);
9191
for (i = 0; i < argc; i++) {
92-
if (info[i]->IsObject() && info[i]->ToObject()->InternalFieldCount()) {
92+
if (info[i]->IsObject() && info[i]->ToObject()->InternalFieldCount() == 2) {
9393
/* This is a PHP object, passed to JS and back. */
9494
argv[i] = reinterpret_cast<zval *>(info[i]->ToObject()->GetAlignedPointerFromInternalField(1));
9595
Z_ADDREF_P(argv[i]);

v8js_v8.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ int v8js_get_properties_hash(v8::Handle<v8::Value> jsValue, HashTable *retval, i
276276
const char *key = ToCString(cstr);
277277
zval *value = NULL;
278278

279-
if (jsVal->IsObject() && jsVal->ToObject()->InternalFieldCount()) {
279+
if (jsVal->IsObject() && jsVal->ToObject()->InternalFieldCount() == 2) {
280280
value = reinterpret_cast<zval *>(jsVal->ToObject()->GetAlignedPointerFromInternalField(1));
281281
Z_ADDREF_P(value);
282282
}

0 commit comments

Comments
 (0)