From: Vsevolod Stakhov Date: Mon, 22 Jul 2024 12:25:39 +0000 (+0100) Subject: [Minor] Ensure some safety when checking weights X-Git-Tag: 3.9.1~1^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=58d13149875a44329c54567387241b642cc96471;p=rspamd.git [Minor] Ensure some safety when checking weights Issue: #5065 --- diff --git a/src/plugins/lua/gpt.lua b/src/plugins/lua/gpt.lua index 7b582e55d..65b5758a8 100644 --- a/src/plugins/lua/gpt.lua +++ b/src/plugins/lua/gpt.lua @@ -106,10 +106,12 @@ local function default_condition(task) if task:has_symbol(s) then if required_weight > 0 then -- Also check score - local sym = task:get_symbol(s) + local sym = task:get_symbol(s) or E -- Must exist as we checked it before with `has_symbol` - if math.abs(sym.weight) >= required_weight then - return false, 'skip as "' .. s .. '" is found (weight: ' .. sym.weight .. ')' + if sym.weight then + if math.abs(sym.weight) >= required_weight then + return false, 'skip as "' .. s .. '" is found (weight: ' .. sym.weight .. ')' + end end lua_util.debugm(N, task, 'symbol %s has weight %s, but required %s', s, sym.weight, required_weight)