Merge pull request #394 from lioncash/bounds

Fix some array bounds-related errors
This commit is contained in:
zilmar 2015-04-17 06:21:08 +10:00
commit 6426b76bfc
2 changed files with 9 additions and 7 deletions

View File

@ -208,10 +208,10 @@ void CMemoryLabel::ProcessCODFile(BYTE * File, DWORD FileLen)
}
}
if (Length > 40)
{
Length = 40;
}
// Stay within label array bounds
if (Length > 39)
Length = 39;
memcpy(Label,CurrentPos,Length);
Label[Length] = '\0';

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);
}