summaryrefslogtreecommitdiff
path: root/Zend/zend.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2015-09-18 17:27:39 +0800
committerXinchen Hui <laruence@gmail.com>2015-09-18 17:27:39 +0800
commit7680194a930165f50194a48e324d11001aef3465 (patch)
treee1a366f0bba01e9bbe61bfafeb2402fa72428dbe /Zend/zend.c
parentd42d0460f8892d6b321a0641e54c5ac97c2d1149 (diff)
downloadphp-git-7680194a930165f50194a48e324d11001aef3465.tar.gz
Fixed bug #70481 (Memory leak in auto_global_copy_ctor() in ZTS build)
Diffstat (limited to 'Zend/zend.c')
-rw-r--r--Zend/zend.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index c521df9ce2..0a70ccc3b5 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -446,26 +446,34 @@ static void zend_init_call_trampoline_op(void) /* {{{ */
}
/* }}} */
+static void auto_global_dtor(zval *zv) /* {{{ */
+{
+ free(Z_PTR_P(zv));
+}
+/* }}} */
+
#ifdef ZTS
-static void function_copy_ctor(zval *zv)
+static void function_copy_ctor(zval *zv) /* {{{ */
{
zend_function *old_func = Z_FUNC_P(zv);
Z_FUNC_P(zv) = pemalloc(sizeof(zend_internal_function), 1);
memcpy(Z_FUNC_P(zv), old_func, sizeof(zend_internal_function));
function_add_ref(Z_FUNC_P(zv));
}
+/* }}} */
-static void auto_global_copy_ctor(zval *zv)
+static void auto_global_copy_ctor(zval *zv) /* {{{ */
{
zend_auto_global *old_ag = (zend_auto_global *) Z_PTR_P(zv);
zend_auto_global *new_ag = pemalloc(sizeof(zend_auto_global), 1);
- new_ag->name = zend_string_copy(old_ag->name);
+ new_ag->name = old_ag->name;
new_ag->auto_global_callback = old_ag->auto_global_callback;
new_ag->jit = old_ag->jit;
Z_PTR_P(zv) = new_ag;
}
+/* }}} */
static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{{ */
{
@@ -482,7 +490,7 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{
zend_set_default_compile_time_values();
compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, 0);
+ zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, auto_global_dtor, 1, 0);
zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, auto_global_copy_ctor);
compiler_globals->last_static_member = zend_hash_num_elements(compiler_globals->class_table);
@@ -609,12 +617,6 @@ static void module_destructor_zval(zval *zv) /* {{{ */
}
/* }}} */
-static void auto_global_dtor(zval *zv) /* {{{ */
-{
- free(Z_PTR_P(zv));
-}
-/* }}} */
-
static zend_bool php_auto_globals_create_globals(zend_string *name) /* {{{ */
{
zval globals;