]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Fix checking table size when inserting/deleting
authorMikhail Galanin <mgalanin@mimecast.com>
Mon, 8 Oct 2018 16:53:33 +0000 (17:53 +0100)
committerMikhail Galanin <mgalanin@mimecast.com>
Mon, 8 Oct 2018 16:53:33 +0000 (17:53 +0100)
lualib/lua_util.lua

index e8fbe2deeffcbce4a667db0ccf869deb571d78d6..3c1a431cf22b46faa4c4b0e427a05bbe74b3783d 100644 (file)
@@ -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