diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-07 13:30:50 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-07 13:30:50 +0100 |
commit | 9964353d374817209248b8b77bceadfb689b4c0b (patch) | |
tree | a7ce889a20843b19842d1437a212a6344f781acd /src/lua | |
parent | 1e84018e2a508ae6c62baf39c2046699ef5b5a52 (diff) | |
download | rspamd-9964353d374817209248b8b77bceadfb689b4c0b.tar.gz rspamd-9964353d374817209248b8b77bceadfb689b4c0b.zip |
[Minor] Allow to call function from stack in rspamd_lua_universal_pcall
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_common.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 53473c9dc..d41e69822 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 |