Skip to content

Commit e869dbf

Browse files
authored
Fixes for CVideoModeManager::GetCurrentAdapterDeviceName
1 parent fef07be commit e869dbf

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Client/core/Graphics/CVideoModeManager.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,18 @@ bool CVideoModeManager::GetCurrentAdapterRect(LPRECT pOutRect)
687687
///////////////////////////////////////////////////////////////
688688
SString CVideoModeManager::GetCurrentAdapterDeviceName()
689689
{
690-
MONITORINFOEX monitorInfo;
690+
if (!m_hCurrentMonitor)
691+
return "";
692+
693+
MONITORINFOEX monitorInfo{};
691694
monitorInfo.cbSize = sizeof(MONITORINFOEX);
692-
if (GetMonitorInfo(m_hCurrentMonitor, &monitorInfo))
693-
return monitorInfo.szDevice;
695+
696+
if (GetMonitorInfoA(m_hCurrentMonitor, &monitorInfo))
697+
{
698+
// Ensure null termination for x86 safety
699+
monitorInfo.szDevice[sizeof(monitorInfo.szDevice) - 1] = '\0';
700+
return SString(monitorInfo.szDevice);
701+
}
702+
694703
return "";
695704
}

0 commit comments

Comments
 (0)