From 64043d5a6c4ca258c40a8c39d0f58fc4a16c86b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 27 Feb 2019 07:51:02 +0100 Subject: php: fix memory leak in functions using hashtable parameters Functions fixed in PHP plugin: - string_eval_expression - string_eval_path_home - key_bind - hook_process_hashtable - hook_hsignal_send - info_get_hashtable - hdata_update --- src/plugins/php/weechat-php-api.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src') diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index 0f9e1a554..e95bf5786 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -566,11 +566,19 @@ API_FUNC(string_eval_expression) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); + result = weechat_string_eval_expression ((const char *)expr, pointers, extra_vars, options); + if (pointers) + weechat_hashtable_free (pointers); + if (extra_vars) + weechat_hashtable_free (extra_vars); + if (options) + weechat_hashtable_free (options); + API_RETURN_STRING_FREE(result); } @@ -603,11 +611,19 @@ API_FUNC(string_eval_path_home) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); + result = weechat_string_eval_path_home ((const char *)path, pointers, extra_vars, options); + if (pointers) + weechat_hashtable_free (pointers); + if (extra_vars) + weechat_hashtable_free (extra_vars); + if (options) + weechat_hashtable_free (options); + API_RETURN_STRING_FREE(result); } @@ -1876,8 +1892,12 @@ API_FUNC(key_bind) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); + result = weechat_key_bind ((const char *)context, keys); + if (keys) + weechat_hashtable_free (keys); + API_RETURN_INT(result); } @@ -2427,6 +2447,9 @@ API_FUNC(hook_process_hashtable) (const char *)callback_name, (const char *)data)); + if (options) + weechat_hashtable_free (options); + API_RETURN_STRING(result); } @@ -2746,8 +2769,12 @@ API_FUNC(hook_hsignal_send) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); + result = weechat_hook_hsignal_send ((const char *)signal, hashtable); + if (hashtable) + weechat_hashtable_free (hashtable); + API_RETURN_INT(result); } @@ -4154,8 +4181,12 @@ API_FUNC(info_get_hashtable) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); + result = weechat_info_get_hashtable ((const char *)info_name, hashtable); + if (hashtable) + weechat_hashtable_free (hashtable); + weechat_php_hashtable_to_array (result, return_value); } @@ -4894,8 +4925,12 @@ API_FUNC(hdata_update) WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); + result = weechat_hdata_update (hdata, pointer, hashtable); + if (hashtable) + weechat_hashtable_free (hashtable); + API_RETURN_INT(result); } -- cgit v1.2.3