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
v2.8-utf8proc
Sébastien Helleu 2019-02-27 07:51:02 +01:00
parent c079cc124e
commit 64043d5a6c
2 changed files with 36 additions and 0 deletions

View File

@ -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::

View File

@ -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);
}