]> source.dussan.org Git - rspamd.git/commitdiff
Fix trie in lua plugins.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 8 Feb 2011 17:14:03 +0000 (20:14 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 8 Feb 2011 17:14:03 +0000 (20:14 +0300)
src/lua/lua_config.c

index 8259ae9a4172823f0f81eb49fead8fddfb77e703..62ea849f5255f504a0daa90ff93025885d93aa82 100644 (file)
@@ -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 */