summaryrefslogtreecommitdiffstats
path: root/lualib/lua_util.lua
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-10-08 17:53:33 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-10-08 17:53:33 +0100
commit41deb94d44828c326c69ca0fb5468058818fedfd (patch)
treec482266c5df3d1cb5e6347ee363e2e04befd0df4 /lualib/lua_util.lua
parent0d25b3158193565a70fecb71ef85342d7cb5b669 (diff)
downloadrspamd-41deb94d44828c326c69ca0fb5468058818fedfd.tar.gz
rspamd-41deb94d44828c326c69ca0fb5468058818fedfd.zip
[Minor] Fix checking table size when inserting/deleting
Diffstat (limited to 'lualib/lua_util.lua')
-rw-r--r--lualib/lua_util.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua
index e8fbe2dee..3c1a431cf 100644
--- a/lualib/lua_util.lua
+++ b/lualib/lua_util.lua
@@ -656,9 +656,14 @@ exports.extract_specific_urls = function(params_or_task, lim, need_emails, filte
for i=1,ntlds / 2 do
local tld1 = tlds[tlds_keys[i]]
local tld2 = tlds[tlds_keys[ntlds - i]]
- table.insert(res, table.remove(tld1))
- table.insert(res, table.remove(tld2))
- limit = limit - 2
+ if #tld1 > 0 then
+ table.insert(res, table.remove(tld1))
+ limit = limit - 1
+ end
+ if #tld2 > 0 then
+ table.insert(res, table.remove(tld2))
+ limit = limit - 1
+ end
if limit <= 0 then
break