From cec24a9efaa5a4dacece6c1ed5a44ac483d83a55 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 8 Feb 2011 20:14:03 +0300 Subject: [PATCH] Fix trie in lua plugins. --- src/lua/lua_config.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 8259ae9a4..62ea849f5 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -691,7 +691,8 @@ lua_trie_search_task (lua_State *L) GList *cur; const gchar *pos, *end; gint id, i = 1; - void *ud; + void *ud; + gboolean found = FALSE; if (trie) { ud = luaL_checkudata (L, 2, "rspamd{task}"); @@ -710,15 +711,22 @@ lua_trie_search_task (lua_State *L) lua_pushinteger (L, id); lua_settable (L, -3); i ++; + found = TRUE; + break; } } cur = g_list_next (cur); } + if (!found) { + lua_pushnil (L); + } return 1; } } - lua_pushnil (L); + if (!found) { + lua_pushnil (L); + } return 1; } /* Init functions */ -- 2.39.5