diff --git a/Library/AboutDialog.cpp b/Library/AboutDialog.cpp index dd9a574e..a4dcf8ea 100644 --- a/Library/AboutDialog.cpp +++ b/Library/AboutDialog.cpp @@ -309,7 +309,7 @@ void UpdateWidgets() if ((*iter).version != 0) { - WCHAR buffer[256]; + WCHAR buffer[64]; swprintf(buffer, L"%i.%i", (*iter).version / 1000, (*iter).version % 1000); ListView_SetItemText(widget, i, 1, buffer); } diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index a20442a2..61a88947 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -697,7 +697,7 @@ std::vector CConfigParser::ReadFloats(LPCTSTR section, LPCTSTR ke int CConfigParser::ReadInt(LPCTSTR section, LPCTSTR key, int defValue) { - TCHAR buffer[256]; + TCHAR buffer[32]; swprintf(buffer, L"%i", defValue); const std::wstring& result = ReadString(section, key, buffer); @@ -752,7 +752,7 @@ int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue) Color CConfigParser::ReadColor(LPCTSTR section, LPCTSTR key, const Color& defValue) { - TCHAR buffer[256]; + TCHAR buffer[128]; swprintf(buffer, L"%i, %i, %i, %i", defValue.GetR(), defValue.GetG(), defValue.GetB(), defValue.GetA()); const std::wstring& result = ReadString(section, key, buffer); diff --git a/Library/Litestep.cpp b/Library/Litestep.cpp index eabe500c..e51f829d 100644 --- a/Library/Litestep.cpp +++ b/Library/Litestep.cpp @@ -520,7 +520,7 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage) { startTime = time; } - WCHAR buffer[MAX_PATH]; + WCHAR buffer[128]; swprintf(buffer, L"(%02i:%02i:%02i.%03i) ", (time - startTime) / (1000 * 60* 60), ((time - startTime) / (1000 * 60)) % 60, ((time - startTime) / 1000) % 60, (time - startTime) % 1000); std::wstring message(buffer); diff --git a/Library/Measure.cpp b/Library/Measure.cpp index 55408a52..49d6ab4e 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -506,8 +506,7 @@ double CMeasure::GetValueRange() const WCHAR* CMeasure::GetStringValue(bool autoScale, double scale, int decimals, bool percentual) { static WCHAR buffer[MAX_LINE_LENGTH]; - static WCHAR buffer2[MAX_LINE_LENGTH]; - double theValue = GetValue(); + WCHAR format[32]; if(percentual) { @@ -515,20 +514,20 @@ const WCHAR* CMeasure::GetStringValue(bool autoScale, double scale, int decimals } else if(autoScale) { - GetScaledValue(decimals, theValue, buffer); + GetScaledValue(decimals, GetValue(), buffer); } else { if(decimals == 0) { - double val = theValue * (1.0 / scale); - val = (val + ( (val >= 0) ? 0.5 : -0.5 ) ); + double val = GetValue() * (1.0 / scale); + val += (val >= 0) ? 0.5 : -0.5; swprintf(buffer, L"%lli", (LONGLONG)val); } else { - swprintf(buffer2, L"%%.%if", decimals); - swprintf(buffer, buffer2, theValue * (1.0 / scale)); + swprintf(format, L"%%.%if", decimals); + swprintf(buffer, format, GetValue() * (1.0 / scale)); } } @@ -537,7 +536,7 @@ const WCHAR* CMeasure::GetStringValue(bool autoScale, double scale, int decimals void CMeasure::GetScaledValue(int decimals, double theValue, WCHAR* buffer) { - WCHAR format[16]; + WCHAR format[32]; double value = 0; if(decimals == 0) diff --git a/Library/MeasureNet.cpp b/Library/MeasureNet.cpp index 0fe9cd72..14056749 100644 --- a/Library/MeasureNet.cpp +++ b/Library/MeasureNet.cpp @@ -586,7 +586,7 @@ void CMeasureNet::ResetStats() */ void CMeasureNet::ReadStats(const std::wstring& iniFile) { - WCHAR buffer[256]; + WCHAR buffer[64]; int count = GetPrivateProfileInt(L"Statistics", L"NetStatsCount", 0, iniFile.c_str()); c_StatValues.clear(); @@ -621,8 +621,8 @@ void CMeasureNet::ReadStats(const std::wstring& iniFile) */ void CMeasureNet::WriteStats(const std::wstring& iniFile) { - WCHAR buffer[256]; - WCHAR buffer2[256]; + WCHAR buffer[32]; + WCHAR buffer2[64]; wsprintf(buffer, L"%i", c_StatValues.size() / 2); WritePrivateProfileString(L"Statistics", L"NetStatsCount", buffer, iniFile.c_str()); diff --git a/Library/Meter.cpp b/Library/Meter.cpp index 85c6a137..eeadb22d 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -541,7 +541,7 @@ std::wstring CMeter::ReplaceMeasures(std::wstring source) return source; } - WCHAR buffer[256]; + WCHAR buffer[64]; // Create the actual text (i.e. replace %1, %2, .. with the measure texts) for (size_t i = 0; i < stringValues.size(); ++i) diff --git a/Library/MeterLine.cpp b/Library/MeterLine.cpp index 875a6983..2467b61f 100644 --- a/Library/MeterLine.cpp +++ b/Library/MeterLine.cpp @@ -92,7 +92,7 @@ void CMeterLine::Initialize() */ void CMeterLine::ReadConfig(const WCHAR* section) { - WCHAR tmpName[256]; + WCHAR tmpName[64]; // Store the current number of lines so we know if the buffer needs to be updated int oldLineCount = (int)m_Colors.size(); diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index 0db1ff34..2bfc7d36 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -215,7 +215,7 @@ void CMeterString::Initialize() */ void CMeterString::ReadConfig(const WCHAR* section) { - WCHAR tmpName[256]; + WCHAR tmpName[64]; // Store the current font values so we know if the font needs to be updated std::wstring oldFontFace = m_FontFace; @@ -418,7 +418,7 @@ bool CMeterString::Update() } else { - WCHAR buffer[256]; + WCHAR buffer[64]; // Create the actual text (i.e. replace %1, %2, .. with the measure texts) std::wstring tmpText = m_Text; diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 502e01bf..92ae0ec4 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -1606,14 +1606,14 @@ void CMeterWindow::ReadConfig() if (!m_WindowX.empty() && m_WindowX[0] == L'(' && m_WindowX[m_WindowX.size() - 1] == L')') { double value = parser.ReadFormula(section, L"WindowX", 0.0); - WCHAR buffer[256]; + WCHAR buffer[32]; swprintf(buffer, L"%i", (int)value); m_WindowX = buffer; } if (!m_WindowY.empty() && m_WindowY[0] == L'(' && m_WindowY[m_WindowY.size() - 1] == L')') { double value = parser.ReadFormula(section, L"WindowY", 0.0); - WCHAR buffer[256]; + WCHAR buffer[32]; swprintf(buffer, L"%i", (int)value); m_WindowY = buffer; } @@ -1682,7 +1682,7 @@ void CMeterWindow::ReadConfig() */ void CMeterWindow::WriteConfig() { - WCHAR buffer[256]; + WCHAR buffer[32]; std::wstring iniFile = m_Rainmeter->GetIniFile(); const WCHAR* section = m_SkinName.c_str(); @@ -1757,7 +1757,7 @@ bool CMeterWindow::ReadSkin() int appVersion = m_Parser.ReadInt(L"Rainmeter", L"AppVersion", 0); if (appVersion > RAINMETER_VERSION) { - WCHAR buffer[256]; + WCHAR buffer[128]; std::wstring text; if (appVersion % 1000 != 0) { @@ -1864,7 +1864,7 @@ bool CMeterWindow::ReadSkin() } // Here we are checking to see if there are more than one local font // to be loaded. They will be named LocalFont2, LocalFont 3, etc. - WCHAR tmpName[256]; + WCHAR tmpName[64]; int i = 2; bool loop = true; do diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index c92c1899..0528eb23 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1643,8 +1643,8 @@ void CRainmeter::CheckSkinVersions() // DebugLog(L"New: %s", strVersionNew.c_str()); // Compare with the version entry in the Rainmeter.ini - WCHAR tmpSz[MAX_LINE_LENGTH] = {0}; - GetPrivateProfileString(menu[i].name.c_str(), L"Version", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()); + WCHAR tmpSz[256] = {0}; + GetPrivateProfileString(menu[i].name.c_str(), L"Version", L"", tmpSz, 256, m_IniFile.c_str()); strVersionInIni = tmpSz; // DebugLog(L"In Ini: %s", strVersionInIni.c_str()); @@ -2827,7 +2827,7 @@ void CRainmeter::ReadGeneralSettings(std::wstring& iniFile) for (UINT i = 1; i <= CSystem::GetMonitorCount(); ++i) { - WCHAR buffer[256]; + WCHAR buffer[64]; wsprintf(buffer, L"DesktopWorkArea@%i", i); area = parser.ReadString(L"Rainmeter", buffer, L""); if (!area.empty()) @@ -3103,7 +3103,7 @@ void CRainmeter::UpdateDesktopWorkArea(bool reset) std::wstring format = L"Applying DesktopWorkArea"; if (i != 0) { - WCHAR buffer[256]; + WCHAR buffer[64]; wsprintf(buffer, L"@%i", i); format += buffer; } @@ -3604,7 +3604,7 @@ void CRainmeter::CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow) for (size_t i = 0; i < monitors.size(); ++i) { - WCHAR buffer[256]; + WCHAR buffer[64]; wsprintf(buffer, L"@%i: ", i + 1); std::wstring item = buffer;