From 58d13149875a44329c54567387241b642cc96471 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 22 Jul 2024 13:25:39 +0100 Subject: [PATCH] [Minor] Ensure some safety when checking weights Issue: #5065 --- src/plugins/lua/gpt.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) -- 2.39.5