diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-28 14:44:21 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-28 14:44:21 +0100 |
commit | b245bc26da34211a8eedd4a7a4cd8fd3f4349331 (patch) | |
tree | 4c1afb4e3c80d3d968daeff01047472eed518d7f /src/plugins/regexp.c | |
parent | 4cd7b6979919dad2dba90c096eb8581bb4266632 (diff) | |
download | rspamd-b245bc26da34211a8eedd4a7a4cd8fd3f4349331.tar.gz rspamd-b245bc26da34211a8eedd4a7a4cd8fd3f4349331.zip |
Do not try to dereference null pointer.
Diffstat (limited to 'src/plugins/regexp.c')
-rw-r--r-- | src/plugins/regexp.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 2bf88ac93..30824949d 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -185,7 +185,7 @@ static gboolean rspamd_lua_call_expression_func( lua_State *L = lua_data->L; struct rspamd_task **ptask; struct expression_argument *arg; - gint pop = 0, i; + gint pop = 0, i, nargs = 0; lua_rawgeti (L, LUA_REGISTRYINDEX, lua_data->idx); /* Now we got function in top of stack */ @@ -194,24 +194,27 @@ static gboolean rspamd_lua_call_expression_func( *ptask = task; /* Now push all arguments */ - for (i = 0; i < (gint)args->len; i ++) { - arg = &g_array_index (args, struct expression_argument, i); - if (arg) { - switch (arg->type) { - case EXPRESSION_ARGUMENT_NORMAL: - lua_pushstring (L, (const gchar *) arg->data); - break; - case EXPRESSION_ARGUMENT_BOOL: - lua_pushboolean (L, (gboolean) GPOINTER_TO_SIZE(arg->data)); - break; - default: - msg_err("cannot pass custom params to lua function"); - return FALSE; + if (args) { + for (i = 0; i < (gint)args->len; i ++) { + arg = &g_array_index (args, struct expression_argument, i); + if (arg) { + switch (arg->type) { + case EXPRESSION_ARGUMENT_NORMAL: + lua_pushstring (L, (const gchar *) arg->data); + break; + case EXPRESSION_ARGUMENT_BOOL: + lua_pushboolean (L, (gboolean) GPOINTER_TO_SIZE(arg->data)); + break; + default: + msg_err("cannot pass custom params to lua function"); + return FALSE; + } } } + nargs = args->len; } - if (lua_pcall (L, args->len, 1, 0) != 0) { + if (lua_pcall (L, nargs + 1, 1, 0) != 0) { msg_info("call to lua function failed: %s", lua_tostring (L, -1)); return FALSE; } |