17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 03:59:19 +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;

View File

@@ -272,10 +272,9 @@ void cParser::stripFirstTokenBOM(std::string& token, bool ToLower, const char* B
}
// if first "token" was standalone BOM, read the next real token (avoid recursion)
while (token.empty() && mStream->peek() != EOF) {
readToken(token, ToLower, Break);
if (token.empty() && mStream->peek() != EOF) {
// readToken will not re-enter BOM stripping because mFirstToken is now false
break;
readToken(token, ToLower, Break);
}
}

View File

@@ -39,7 +39,7 @@ class cParser //: public std::stringstream
Output_
getToken( bool const ToLower = true, char const *Break = "\n\r\t ;" ) {
getTokens( 1, ToLower, Break );
Output_ output;
Output_ output{};
*this >> output;
return output; };
inline