diff --git a/Source/Project64/N64 System/Mips/Memory Labels Class.cpp b/Source/Project64/N64 System/Mips/Memory Labels Class.cpp index 243e19b31..2830e3141 100644 --- a/Source/Project64/N64 System/Mips/Memory Labels Class.cpp +++ b/Source/Project64/N64 System/Mips/Memory Labels Class.cpp @@ -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'; diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index ba41100ce..1bc9df7f8 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -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); }