From 41deb94d44828c326c69ca0fb5468058818fedfd Mon Sep 17 00:00:00 2001 From: Mikhail Galanin Date: Mon, 8 Oct 2018 17:53:33 +0100 Subject: [PATCH] [Minor] Fix checking table size when inserting/deleting --- lualib/lua_util.lua | 11 ++++++++--- 1 file 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 -- 2.39.5