Fixed the issue that Rainmeter crashes if a invalid format parameter is specified in MeasureTime/MeasureUptime.

This commit is contained in:
spx
2010-08-07 19:03:58 +00:00
parent 6f919cfa3f
commit 701178766d
3 changed files with 51 additions and 4 deletions

View File

@ -93,7 +93,15 @@ const WCHAR* CMeasureUptime::GetStringValue(bool autoScale, double scale, int de
time[2] %= 24;
}
FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, m_Format.c_str(), 0, 0, buffer, MAX_LINE_LENGTH, (char**)time);
__try
{
FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, m_Format.c_str(), 0, 0, buffer, MAX_LINE_LENGTH, (char**)time);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
DebugLog(L"Uptime: Invalid Format: Measure=[%s], Format=\"%s\"", m_Name.c_str(), m_Format.c_str());
buffer[0] = 0;
}
return CheckSubstitute(buffer);
}