diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2019-02-27 07:51:02 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-02-27 07:51:02 +0100 |
commit | 64043d5a6c4ca258c40a8c39d0f58fc4a16c86b9 (patch) | |
tree | a31bdb45a8e649d84cb0c8b744f54b7946d5b3d2 | |
parent | c079cc124e67d3f0826ff4b3ba637617273f9023 (diff) | |
download | weechat-64043d5a6c4ca258c40a8c39d0f58fc4a16c86b9.zip |
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
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | src/plugins/php/weechat-php-api.c | 35 |
2 files changed, 36 insertions, 0 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 01f02c259..1649d47d9 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -28,6 +28,7 @@ Bug fixes:: * core: refilter only affected buffers on filter change (issue #1309, issue #1311) * fset: fix slow refresh of fset buffer during /reload (issue #1313) + * php: fix memory leak in functions string_eval_expression, string_eval_path_home, key_bind, hook_process_hashtable, hook_hsignal_send, info_get_hashtable, hdata_update * spell: fix detection of nick followed by the nick completer (issue #1306, issue #1307) Build:: 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); } |