summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/plugins/lua/weechat-lua.c56
2 files changed, 32 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 332b2f25d..1535f5cf4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
-v0.4.1-dev, 2013-03-12
+v0.4.1-dev, 2013-03-13
This document lists all changes for each version.
@@ -54,6 +54,8 @@ Version 0.4.1 (under dev!)
the first server in the list)
* irc: add color in output of /names when result is on server buffer (channel
not joined) (bug #38070)
+* lua: fix crash on stack overflow: call lua_pop() for values returned by lua
+ functions (bug #38510)
* perl: simplify code to load scripts
* relay: add message "_nicklist_diff" (differences between old and current
nicklist)
diff --git a/src/plugins/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c
index cdd4990e4..ccc57fd63 100644
--- a/src/plugins/lua/weechat-lua.c
+++ b/src/plugins/lua/weechat-lua.c
@@ -198,7 +198,34 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
}
}
- if (lua_pcall (lua_current_interpreter, argc, 1, 0) != 0)
+ ret_value = NULL;
+
+ if (lua_pcall (lua_current_interpreter, argc, 1, 0) == 0)
+ {
+ if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
+ {
+ ret_value = strdup ((char *) lua_tostring (lua_current_interpreter, -1));
+ }
+ else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
+ {
+ ret_i = malloc (sizeof (*ret_i));
+ if (ret_i)
+ *ret_i = lua_tonumber (lua_current_interpreter, -1);
+ ret_value = ret_i;
+ }
+ else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
+ {
+ ret_value = weechat_lua_tohashtable (lua_current_interpreter, -1,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+ }
+ else
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, function);
+ }
+ }
+ else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: unable to run function \"%s\""),
@@ -207,34 +234,9 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
weechat_gettext ("%s%s: error: %s"),
weechat_prefix ("error"), LUA_PLUGIN_NAME,
lua_tostring (lua_current_interpreter, -1));
- lua_current_script = old_lua_current_script;
- lua_current_interpreter = old_lua_current_interpreter;
- return NULL;
}
- if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
- ret_value = strdup ((char *) lua_tostring (lua_current_interpreter, -1));
- else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
- {
- ret_i = malloc (sizeof (*ret_i));
- if (ret_i)
- *ret_i = lua_tonumber (lua_current_interpreter, -1);
- ret_value = ret_i;
- }
- else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
- {
- ret_value = weechat_lua_tohashtable (lua_current_interpreter, -1,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING);
- }
- else
- {
- WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, function);
- lua_current_script = old_lua_current_script;
- lua_current_interpreter = old_lua_current_interpreter;
- return NULL;
- }
+ lua_pop (lua_current_interpreter, 1);
lua_current_script = old_lua_current_script;
lua_current_interpreter = old_lua_current_interpreter;