summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-08 16:36:50 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-08 16:36:50 +0000
commite0f78d9f32931f89488d7a6dff8b937408f6de5a (patch)
treeeda9c904ab6d920560a5b0b74930e15d10e31d26 /src
parent7c2e2dc6d631ff5090fb1120bcfc9a6389f44e6a (diff)
downloadrspamd-e0f78d9f32931f89488d7a6dff8b937408f6de5a.tar.gz
rspamd-e0f78d9f32931f89488d7a6dff8b937408f6de5a.zip
[Fix] Fix issue with task:get_symbol and symbols with no metric
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_task.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 0075d1d06..7889d227d 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -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) {