From c06a2ff411a92861e4a617bb5d9d2d1ecb130fe2 Mon Sep 17 00:00:00 2001 From: L7NEG Date: Mon, 14 Sep 2026 15:42:45 +0300 Subject: [PATCH] Harden legacy config file handling Use the native io.exists helper and return nil when config reads fail instead of raising fatal errors, allowing callers to handle missing or unreadable configuration files gracefully. --- YimMenu/Ultimate_Menu_Legacy.lua | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/YimMenu/Ultimate_Menu_Legacy.lua b/YimMenu/Ultimate_Menu_Legacy.lua index 66cdf97..33e99f5 100644 --- a/YimMenu/Ultimate_Menu_Legacy.lua +++ b/YimMenu/Ultimate_Menu_Legacy.lua @@ -4528,13 +4528,7 @@ function YimConfig(DEFAULT_CONFIG) } function file_exists(name) - local f = io.open(name, "r") - if f ~= nil then - f:close() - return true - else - return false - end + return io.exists(name) end local writeToFile = function(data) @@ -4575,7 +4569,7 @@ function YimConfig(DEFAULT_CONFIG) else config = readFromFile() if config == nil then - error("[FATAL] Failed to read config file!") + return nil end for key, defaultValue in pairs(DEFAULT_CONFIG) do @@ -4589,7 +4583,7 @@ function YimConfig(DEFAULT_CONFIG) local readAndDecodeConfig = function() if not checkAndCreateConfig() then - error("Failed to read config file!", 2) + return nil end return readFromFile() end