Browse Source

Fix ZTS build + memory leak

Stefan Siegl 10 năm trước cách đây
mục cha
commit
94a889b2cb
1 tập tin đã thay đổi với 10 bổ sung0 xóa
  1. 10 0
      v8js_array_access.cc

+ 10 - 0
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<v8::Object> self = info.Holder();
 
+	V8JS_TSRMLS_FETCH();
+
 	zval *object = reinterpret_cast<zval *>(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<v8::Value> va
 	v8::Isolate *isolate = info.GetIsolate();
 	v8::Local<v8::Object> self = info.Holder();
 
+	V8JS_TSRMLS_FETCH();
+
 	zval *object = reinterpret_cast<zval *>(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<v8::Value> 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<v8::String> property, const v
 	v8::Isolate *isolate = info.GetIsolate();
 	v8::Local<v8::Object> self = info.Holder();
 
+	V8JS_TSRMLS_FETCH();
+
 	zval *object = reinterpret_cast<zval *>(self->GetAlignedPointerFromInternalField(0));
 	zend_class_entry *ce = Z_OBJCE_P(object);