diff options
author | Xinchen Hui <laruence@php.net> | 2014-05-08 15:20:13 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2014-05-08 15:20:13 +0800 |
commit | c242518bf0d2c3132c60c8f8dfba64329f73e90e (patch) | |
tree | 8155972d987353d935606b3166bda5de2b7844c8 /sapi | |
parent | 5f46c8fa31a8cfa0ad03b9aebd04243a09ac7be1 (diff) | |
download | php-git-c242518bf0d2c3132c60c8f8dfba64329f73e90e.tar.gz |
There should been memory leaks(and don't use pointer cast)
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/cgi/cgi_main.c | 6 | ||||
-rw-r--r-- | sapi/fpm/fpm/fpm_main.c | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 4253e6978a..cb76caaa93 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -187,10 +187,12 @@ typedef struct _user_config_cache_entry { HashTable *user_config; } user_config_cache_entry; -static void user_config_cache_entry_dtor(user_config_cache_entry *entry) +static void user_config_cache_entry_dtor(zval *el) { + user_config_cache_entry *entry = (user_config_cache_entry *)Z_PTR_P(el); zend_hash_destroy(entry->user_config); free(entry->user_config); + free(entry); } /* }}} */ @@ -1476,7 +1478,7 @@ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals TSRMLS_ #ifdef PHP_WIN32 php_cgi_globals->impersonate = 0; #endif - zend_hash_init(&php_cgi_globals->user_config_cache, 8, NULL, (dtor_func_t) user_config_cache_entry_dtor, 1); + zend_hash_init(&php_cgi_globals->user_config_cache, 8, NULL, user_config_cache_entry_dtor, 1); } /* }}} */ diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 6b9abc859f..78566be956 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -188,10 +188,12 @@ typedef struct _user_config_cache_entry { HashTable *user_config; } user_config_cache_entry; -static void user_config_cache_entry_dtor(user_config_cache_entry *entry) +static void user_config_cache_entry_dtor(zval *el) { + user_config_cache_entry *entry = (user_config_cache_entry *)Z_PTR_P(el); zend_hash_destroy(entry->user_config); free(entry->user_config); + free(entry); } /* }}} */ @@ -691,7 +693,7 @@ static void php_cgi_ini_activate_user_config(char *path, int path_len, const cha entry = pemalloc(sizeof(user_config_cache_entry), 1); entry->expires = 0; entry->user_config = (HashTable *) pemalloc(sizeof(HashTable), 1); - zend_hash_init(entry->user_config, 0, NULL, (dtor_func_t) config_zval_dtor, 1); + zend_hash_init(entry->user_config, 0, NULL, config_zval_dtor, 1); zend_hash_str_update_ptr(&CGIG(user_config_cache), path, path_len, entry); } @@ -1455,7 +1457,7 @@ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals TSRMLS_ php_cgi_globals->fix_pathinfo = 1; php_cgi_globals->discard_path = 0; php_cgi_globals->fcgi_logging = 1; - zend_hash_init(&php_cgi_globals->user_config_cache, 0, NULL, (dtor_func_t) user_config_cache_entry_dtor, 1); + zend_hash_init(&php_cgi_globals->user_config_cache, 0, NULL, user_config_cache_entry_dtor, 1); php_cgi_globals->error_header = NULL; php_cgi_globals->fpm_config = NULL; } |