1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 06:46:38 +02:00

scripts: fix memory leak in hook_info callback

This commit is contained in:
Sébastien Helleu
2018-04-13 19:55:20 +02:00
parent cc06b95ba7
commit 9265acf879
19 changed files with 122 additions and 46 deletions
+9 -5
View File
@@ -67,6 +67,8 @@
plugin_script_str2ptr (weechat_lua_plugin, \
LUA_CURRENT_SCRIPT_NAME, \
lua_function_name, __string)
#define API_STATIC_STRING(__string) \
plugin_script_get_static_string(&lua_data, __string);
#define API_RETURN_OK \
lua_pushinteger (L, 1); \
return 1
@@ -2994,7 +2996,7 @@ weechat_lua_api_hook_info_cb (const void *pointer, void *data,
{
struct t_plugin_script *script;
void *func_argv[3];
char empty_arg[1] = { '\0' };
char empty_arg[1] = { '\0' }, *result;
const char *ptr_function, *ptr_data;
script = (struct t_plugin_script *)pointer;
@@ -3006,10 +3008,12 @@ weechat_lua_api_hook_info_cb (const void *pointer, void *data,
func_argv[1] = (info_name) ? (char *)info_name : empty_arg;
func_argv[2] = (arguments) ? (char *)arguments : empty_arg;
return (const char *)weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
ptr_function,
"sss", func_argv);
result = (char *)weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_STRING,
ptr_function,
"sss", func_argv);
return API_STATIC_STRING(result);
}
return NULL;
+1 -1
View File
@@ -1281,12 +1281,12 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
{
/* unload all scripts */
lua_quiet = 1;
plugin_script_end (plugin, &lua_data);
if (lua_script_eval)
{
weechat_lua_unload (lua_script_eval);
lua_script_eval = NULL;
}
plugin_script_end (plugin, &lua_data);
lua_quiet = 0;
/* free some data */