Notification Class: Correct array sizing in SetWindowCaption

sizeof(wchar_t) is a size of 2 (or 4 if in a Linux environment). With the previous code, it would be trying to insert the null terminator at index 511 on Windows, which is incorrect.
This commit is contained in:
Lioncash 2015-04-16 15:49:48 -04:00
parent a7eb2e79e5
commit e9c056e5a4
1 changed files with 5 additions and 3 deletions

View File

@ -147,9 +147,11 @@ void CNotification::SetGfxPlugin( CGfxPlugin * Plugin )
void CNotification::SetWindowCaption (const wchar_t * Caption)
{
wchar_t WinTitle[256];
_snwprintf( WinTitle, sizeof(WinTitle), L"%s - %s", Caption, g_Settings->LoadString(Setting_ApplicationName).ToUTF16().c_str());
WinTitle[sizeof(WinTitle) - 1] = 0;
static const size_t TITLE_SIZE = 256;
wchar_t WinTitle[TITLE_SIZE];
_snwprintf(WinTitle, TITLE_SIZE, L"%s - %s", Caption, g_Settings->LoadString(Setting_ApplicationName).ToUTF16().c_str());
WinTitle[TITLE_SIZE - 1] = 0;
m_hWnd->Caption(WinTitle);
}