diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2018-04-13 19:55:20 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2018-04-13 19:55:20 +0200 |
commit | 9265acf87945426f765b068dd660995c0e8661f7 (patch) | |
tree | 487d4179ef2e5406d21413b189fe8281dfb273b7 /src/plugins/python/weechat-python-api.c | |
parent | cc06b95ba7b52595d9313606966d380592c9acf9 (diff) | |
download | weechat-9265acf87945426f765b068dd660995c0e8661f7.zip |
scripts: fix memory leak in hook_info callback
Diffstat (limited to 'src/plugins/python/weechat-python-api.c')
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 8d8718c80..82399b494 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -59,6 +59,8 @@ plugin_script_str2ptr (weechat_python_plugin, \ PYTHON_CURRENT_SCRIPT_NAME, \ python_function_name, __string) +#define API_STATIC_STRING(__string) \ + plugin_script_get_static_string(&python_data, __string); #define API_RETURN_OK return PyLong_FromLong((long)1) #define API_RETURN_ERROR return PyLong_FromLong ((long)0) #define API_RETURN_EMPTY \ @@ -2948,7 +2950,7 @@ weechat_python_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; @@ -2960,10 +2962,12 @@ weechat_python_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_python_exec (script, - WEECHAT_SCRIPT_EXEC_STRING, - ptr_function, - "sss", func_argv); + result = (char *)weechat_python_exec (script, + WEECHAT_SCRIPT_EXEC_STRING, + ptr_function, + "sss", func_argv); + + return API_STATIC_STRING(result); } return NULL; |