From 592d6528cae6d7a4eabbbc4c374d66255999b88f Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Sun, 30 Aug 2015 00:26:55 +0200 Subject: [PATCH] PHP7 adapt: fix zend_string memory leaks --- v8js_array_access.cc | 2 +- v8js_object_export.cc | 4 +++- v8js_v8.cc | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/v8js_array_access.cc b/v8js_array_access.cc index a501359..c8aa300 100644 --- a/v8js_array_access.cc +++ b/v8js_array_access.cc @@ -32,7 +32,6 @@ static zval v8js_array_access_dispatch(zend_object *object, const char *method_n { zend_fcall_info fci; zval php_value; - ZVAL_UNDEF(&php_value); fci.size = sizeof(fci); fci.function_table = &object->ce->function_table; @@ -51,6 +50,7 @@ static zval v8js_array_access_dispatch(zend_object *object, const char *method_n fci.no_separation = 0; zend_call_function(&fci, NULL TSRMLS_CC); + zval_dtor(&fci.function_name); return php_value; } /* }}} */ diff --git a/v8js_object_export.cc b/v8js_object_export.cc index bf4efa5..181b07f 100644 --- a/v8js_object_export.cc +++ b/v8js_object_export.cc @@ -48,7 +48,7 @@ static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, v max_num_args = method_ptr->common.num_args; /* Function name to call */ - ZVAL_STRING(&fname, ZSTR_VAL(method_ptr->common.function_name)); + ZVAL_STR_COPY(&fname, method_ptr->common.function_name); /* zend_fcall_info */ fci.size = sizeof(fci); @@ -78,6 +78,7 @@ static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, v } efree(error); info.GetReturnValue().Set(return_value); + zval_dtor(&fname); return; } @@ -147,6 +148,7 @@ failure: return_value = zval_to_v8js(&retval, isolate TSRMLS_CC); zval_dtor(&retval); + zval_dtor(&fname); info.GetReturnValue().Set(return_value); } diff --git a/v8js_v8.cc b/v8js_v8.cc index 4314901..8401060 100644 --- a/v8js_v8.cc +++ b/v8js_v8.cc @@ -252,6 +252,8 @@ int v8js_get_properties_hash(v8::Handle jsValue, HashTable *retval, i } else { zend_hash_update(retval, key, &value); } + + zend_string_release(key); } return SUCCESS; }