commit f778850: [Minor] Fix number of arguments to invoke a lua function

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Sep 1 14:21:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-09-01 15:14:43 +0100
URL: https://github.com/rspamd/rspamd/commit/f778850980db0ff24b462b169d2ded48000dd5c6 (HEAD -> master)

[Minor] Fix number of arguments to invoke a lua function

---
 src/libstat/stat_process.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c
index 4e856b563..13083986f 100644
--- a/src/libstat/stat_process.c
+++ b/src/libstat/stat_process.c
@@ -201,6 +201,7 @@ rspamd_stat_classifier_is_skipped (struct rspamd_task *task,
 	while (cur) {
 		gint cb_ref = GPOINTER_TO_INT (cur->data);
 		gint old_top = lua_gettop (L);
+		gint nargs;
 
 		lua_rawgeti (L, LUA_REGISTRYINDEX, cb_ref);
 		/* Push task and two booleans: is_spam and is_unlearn */
@@ -212,9 +213,13 @@ rspamd_stat_classifier_is_skipped (struct rspamd_task *task,
 			lua_pushboolean(L, is_spam);
 			lua_pushboolean(L,
 					task->flags & RSPAMD_TASK_FLAG_UNLEARN ? true : false);
+			nargs = 3;
+		}
+		else {
+			nargs = 1;
 		}
 
-		if (lua_pcall (L, 3, LUA_MULTRET, 0) != 0) {
+		if (lua_pcall (L, nargs, LUA_MULTRET, 0) != 0) {
 			msg_err_task ("call to %s failed: %s",
 					"condition callback",
 					lua_tostring (L, -1));


More information about the Commits mailing list