17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-18 06:49:18 +02:00

fix(sonar): addressing reliability/security issues (#202)

This commit is contained in:
jerrrrycho
2026-10-04 20:00:13 +02:00
committed by GitHub
parent 51521a135a
commit 79bd0c8e91
36 changed files with 254 additions and 246 deletions

View File

@@ -80,29 +80,20 @@ std::mutex logMutex;
void LogService()
{
// prevent crash if mutex is not initialized
while (true)
{
try
{
logMutex.lock();
break;
}
catch (...) {}
}
logMutex.unlock();
while (!Global.applicationQuitOrder)
{
{
// --- Obsługa InfoStack ---
while (!InfoStack.empty())
{
logMutex.lock();
std::string msg = InfoStack.front().first;
bool isError = InfoStack.front().second;
InfoStack.pop_front();
logMutex.unlock();
std::string msg;
bool isError;
{
std::scoped_lock lock(logMutex);
msg = InfoStack.front().first;
isError = InfoStack.front().second;
InfoStack.pop_front();
}
// log to file
if (Global.iWriteLogEnabled & 1)
@@ -134,10 +125,12 @@ void LogService()
// --- Obsługa ErrorStack ---
while (!ErrorStack.empty())
{
logMutex.lock();
std::string msg = ErrorStack.front();
ErrorStack.pop_front();
logMutex.unlock();
std::string msg;
{
std::scoped_lock lock(logMutex);
msg = ErrorStack.front();
ErrorStack.pop_front();
}
if (!(Global.iWriteLogEnabled & 1))
continue;