From 425a8aaba8d7a48688d323baffcd682776f03d9e Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Sun, 22 Jun 2025 19:55:20 -0700 Subject: [PATCH] Group: add new protections for unexpected edge cases Early return of sDir or sGroupDirName is empty, and check the return value of ini.ReadFile instead of assuming the ini file was successfully read. --- src/Group.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Group.cpp b/src/Group.cpp index df11659514..8c7b60fab2 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -42,6 +42,11 @@ Group::~Group() } Group::Group(const RString& sDir, const RString& sGroupDirName, bool bFromProfile) { + if (sDir.empty() || sGroupDirName.empty()) { + LOG->Warn("Group::Group: Empty directory or group name provided."); + return; + } + RString sPackIniPath; if (bFromProfile) { sPackIniPath = sDir + "/" + INI_FILE; @@ -72,7 +77,12 @@ Group::Group(const RString& sDir, const RString& sGroupDirName, bool bFromProfil if (FILEMAN->DoesFileExist(sPackIniPath)) { IniFile ini; - ini.ReadFile(sPackIniPath); + if (!ini.ReadFile(sPackIniPath)) { + LOG->Warn( + "Group::Group: Failed to read Pack.ini file at '%s': %s", + sPackIniPath.c_str(), ini.GetError().c_str()); + return; + } RString sVersion = ""; ini.GetValue("Group", "Version", sVersion);