From 94a889b2cb00fc653f490ed8ed5b5fea7a54cd43 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Tue, 25 Nov 2014 22:55:17 +0000 Subject: [PATCH] Fix ZTS build + memory leak --- v8js_array_access.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/v8js_array_access.cc b/v8js_array_access.cc index b1223ca..9eebb8f 100644 --- a/v8js_array_access.cc +++ b/v8js_array_access.cc @@ -30,6 +30,8 @@ static void php_v8js_array_access_getter(uint32_t index, const v8::PropertyCallb v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); + V8JS_TSRMLS_FETCH(); + zval *object = reinterpret_cast(self->GetAlignedPointerFromInternalField(0)); zend_class_entry *ce = Z_OBJCE_P(object); @@ -74,6 +76,8 @@ static void php_v8js_array_access_setter(uint32_t index, v8::Local va v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); + V8JS_TSRMLS_FETCH(); + zval *object = reinterpret_cast(self->GetAlignedPointerFromInternalField(0)); zend_class_entry *ce = Z_OBJCE_P(object); @@ -117,6 +121,10 @@ static void php_v8js_array_access_setter(uint32_t index, v8::Local va /* simply pass back the value to tell we intercepted the call * as the offsetSet function returns void. */ info.GetReturnValue().Set(value); + + /* if PHP wanted to hold on to this value, zend_call_function would + * have bumped the refcount. */ + zval_ptr_dtor(&zvalue_ptr); } /* }}} */ @@ -125,6 +133,8 @@ static void php_v8js_array_access_length(v8::Local property, const v v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); + V8JS_TSRMLS_FETCH(); + zval *object = reinterpret_cast(self->GetAlignedPointerFromInternalField(0)); zend_class_entry *ce = Z_OBJCE_P(object);