com php-src: Fixed bug #70481 (Memory leak in auto_global_c opy_ctor() in ZTS build): NEWS Zend/zend. c

From: Date: Fri, 18 Sep 2015 09:27:39 +0000
Subject: com php-src: Fixed bug #70481 (Memory leak in auto_global_c opy_ctor() in ZTS build): NEWS Zend/zend. c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89070@lists.php.net to get a copy of this message
Commit: 7680194a930165f50194a48e324d11001aef3465 Author: Xinchen Hui <laruence@gmail.com> Fri, 18 Sep 2015 17:27:39 +0800 Parents: d42d0460f8892d6b321a0641e54c5ac97c2d1149 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7680194a930165f50194a48e324d11001aef3465 Log: Fixed bug #70481 (Memory leak in auto_global_copy_ctor() in ZTS build) Bugs: https://bugs.php.net/70481 Changed paths: M NEWS M Zend/zend.c Diff: diff --git a/NEWS b/NEWS index 93b8999..fb99eb0 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 01 Oct 2015, PHP 7.0.0 RC 4 +- Core: + . Fixed bug #70481 (Memory leak in auto_global_copy_ctor() in ZTS build). + (Laruence) 17 Sep 2015, PHP 7.0.0 RC 3 diff --git a/Zend/zend.c b/Zend/zend.c index c521df9..0a70ccc 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;

« previous php.cvs (#89070) next »