From edb8609cfea146b64e0341a1b35d5f3dd9a1e354 Mon Sep 17 00:00:00 2001 From: Patrick Reilly Date: Thu, 9 May 2013 15:34:25 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20for=20https://github.com/preillyme/v8js/i?= =?UTF-8?q?ssues/6.=20This=20is=20probably=20=E2=80=A6=20=E2=80=A6=20horri?= =?UTF-8?q?ble=20hack=20but=20it=20works=20for=20now=20until=20we=20have?= =?UTF-8?q?=20a=20better=20solution.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v8js_convert.cc | 7 +++++++ 1 file changed, 7 insertions(+) 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"));