summaryrefslogtreecommitdiff
path: root/src/plugins/lua/weechat-lua-api.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2018-04-13 19:55:20 +0200
committerSébastien Helleu <flashcode@flashtux.org>2018-04-13 19:55:20 +0200
commit9265acf87945426f765b068dd660995c0e8661f7 (patch)
tree487d4179ef2e5406d21413b189fe8281dfb273b7 /src/plugins/lua/weechat-lua-api.c
parentcc06b95ba7b52595d9313606966d380592c9acf9 (diff)
downloadweechat-9265acf87945426f765b068dd660995c0e8661f7.zip
scripts: fix memory leak in hook_info callback
Diffstat (limited to 'src/plugins/lua/weechat-lua-api.c')
-rw-r--r--src/plugins/lua/weechat-lua-api.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index 8938522e3..1224042de 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -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;