diff --git a/v8js_convert.cc b/v8js_convert.cc index a6ff654..b95e253 100644 --- a/v8js_convert.cc +++ b/v8js_convert.cc @@ -384,6 +384,13 @@ static v8::Handle php_v8js_hash_to_jsobj(zval *value TSRMLS_DC) /* {{ newobj->SetHiddenValue(V8JS_SYM(ZEND_ISSET_FUNC_NAME), PHP_V8JS_CALLBACK(isset_ptr)); } } + + // See https://github.com/preillyme/v8js/issues/6 + if (Z_REFCOUNT_P(value) == 1) + { + Z_SET_REFCOUNT_P(value, 2); + } + newobj->SetAlignedPointerInInternalField(0, (void *) value); } else { new_tpl->SetClassName(V8JS_SYM("Array"));