]> granicus.if.org Git - php/commitdiff
There should been memory leaks(and don't use pointer cast)
authorXinchen Hui <laruence@php.net>
Thu, 8 May 2014 07:20:13 +0000 (15:20 +0800)
committerXinchen Hui <laruence@php.net>
Thu, 8 May 2014 07:20:13 +0000 (15:20 +0800)
main/php_ini.c
sapi/cgi/cgi_main.c
sapi/fpm/fpm/fpm_main.c

index d7427127585e1aa3898b5f70c64b296878f507bd..cdd4a61fb5db61f97db49b49d08b30429822c74c 100644 (file)
@@ -262,7 +262,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
                                /* If option not found in hash or is not an array -> create array, otherwise add to existing array */
                                if ((find_arr = zend_hash_find(active_hash, Z_STR_P(arg1))) == NULL || Z_TYPE_P(find_arr) != IS_ARRAY) {
                                        ZVAL_NEW_PERSISTENT_ARR(&option_arr);
-                                       zend_hash_init(Z_ARRVAL(option_arr), 8, NULL, (dtor_func_t) config_zval_dtor, 1);
+                                       zend_hash_init(Z_ARRVAL(option_arr), 8, NULL, config_zval_dtor, 1);
                                        find_arr = zend_hash_update(active_hash, Z_STR_P(arg1), &option_arr);
                                }
 
@@ -386,7 +386,7 @@ int php_init_config(TSRMLS_D)
        int free_ini_search_path = 0;
        zend_file_handle fh;
 
-       zend_hash_init(&configuration_hash, 8, NULL, (dtor_func_t) config_zval_dtor, 1);
+       zend_hash_init(&configuration_hash, 8, NULL, config_zval_dtor, 1);
 
        if (sapi_module.ini_defaults) {
                sapi_module.ini_defaults(&configuration_hash);
index 4253e6978afedf8ff756adbc15b16c86a8b1b74e..cb76caaa93a05fcb741eb5ea403ec7313565d50b 100644 (file)
@@ -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);
 }
 /* }}} */
 
index 6b9abc859f77426d179e463bde54b48c17bb3c1c..78566be956131534ad39f53925da261beb3fb6e8 100644 (file)
@@ -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;
 }