diff options
-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 |