From: Vsevolod Stakhov Date: Mon, 7 Aug 2023 12:30:50 +0000 (+0100) Subject: [Minor] Allow to call function from stack in rspamd_lua_universal_pcall X-Git-Tag: 3.7.1~94 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9964353d374817209248b8b77bceadfb689b4c0b;p=thirdparty%2Frspamd.git [Minor] Allow to call function from stack in rspamd_lua_universal_pcall --- diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 53473c9dc7..d41e69822e 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -2555,7 +2555,13 @@ bool rspamd_lua_universal_pcall(lua_State *L, gint cbref, const gchar *strloc, va_start(ap, err); /* Called function */ - lua_rawgeti(L, LUA_REGISTRYINDEX, cbref); + if (cbref > 0) { + lua_rawgeti(L, LUA_REGISTRYINDEX, cbref); + } + else { + /* Assume that function was on top of the stack */ + lua_pushvalue(L, err_idx - 1); + } /* * Possible arguments * - i - lua_integer, argument - gint64