]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix issue with task:get_symbol and symbols with no metric
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 8 Mar 2017 16:36:50 +0000 (16:36 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 8 Mar 2017 16:36:50 +0000 (16:36 +0000)
src/lua/lua_task.c

index 0075d1d068feccc51709d5a12fb50727492f3785..7889d227d8d97c862090224cc02fb1e0850f2aa4 100644 (file)
@@ -2718,7 +2718,7 @@ lua_push_symbol_result (lua_State *L,
        if (metric_res) {
                if ((s = g_hash_table_lookup (metric_res->symbols, symbol)) != NULL) {
                        j = 1;
-                       lua_newtable (L);
+                       lua_createtable (L, 0, 5);
                        lua_pushstring (L, "metric");
                        lua_pushstring (L, metric->name);
                        lua_settable (L, -3);
@@ -2775,7 +2775,7 @@ lua_task_get_symbol (lua_State *L)
        if (task && symbol) {
                metric_list = g_hash_table_lookup (task->cfg->metrics_symbols, symbol);
                if (metric_list) {
-                       lua_newtable (L);
+                       lua_createtable (L, 1, 0);
                        cur = metric_list;
                }
                else {
@@ -2783,10 +2783,15 @@ lua_task_get_symbol (lua_State *L)
                }
 
                if (!cur && metric) {
+                       lua_createtable (L, 1, 0);
+
                        if ((found = lua_push_symbol_result (L, task, metric, symbol))) {
-                               lua_newtable (L);
                                lua_rawseti (L, -2, i++);
                        }
+                       else {
+                               /* Pop table */
+                               lua_pop (L, 1);
+                       }
                }
                else {
                        while (cur) {