wLength = GetWindowsDirectoryW(DestString, MaxStrLen);
if ((wLength > 0) && (_wcsnicmp(ConsoleName, DestString, wLength) == 0))
{
- wcsncpy(DestString, L"%SystemRoot%", MaxStrLen);
- // FIXME: Fix possible buffer overflows there !!!!!
- wcsncat(DestString, ConsoleName + wLength, MaxStrLen);
+ StringCchCopyW(DestString, MaxStrLen, L"%SystemRoot%");
+ StringCchCatW(DestString, MaxStrLen, ConsoleName + wLength);
}
else
{
- wcsncpy(DestString, ConsoleName, MaxStrLen);
+ StringCchCopyW(DestString, MaxStrLen, ConsoleName);
}
/* Replace path separators (backslashes) by underscores */
* to make the registry happy, replace all the
* backslashes by underscores.
*/
- TranslateConsoleName(szBuffer2, ConsoleTitle, MAX_PATH);
+ TranslateConsoleName(szBuffer2, ConsoleTitle, ARRAYSIZE(szBuffer2));
/* Create the registry path */
- wcsncat(szBuffer, szBuffer2, MAX_PATH - wcslen(szBuffer) - 1);
+ StringCchCatW(szBuffer, MAX_PATH - wcslen(szBuffer) - 1, szBuffer2);
/* Create or open the registry key */
if (Create)
{
PGUI_CONSOLE_DATA GuiData = GuiGetGuiData(hWnd);
- if (GuiData->IsWindowVisible)
- {
- KillTimer(hWnd, CONGUI_UPDATE_TIMER);
- }
+ /* Free the GuiData registration */
+ SetWindowLongPtrW(hWnd, GWLP_USERDATA, (DWORD_PTR)NULL);
GetSystemMenu(hWnd, TRUE);
if (GuiData)
{
+ if (GuiData->IsWindowVisible)
+ KillTimer(hWnd, CONGUI_UPDATE_TIMER);
+
/* Free the terminal framebuffer */
if (GuiData->hMemDC ) DeleteDC(GuiData->hMemDC);
if (GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
DeleteFonts(GuiData);
}
- /* Free the GuiData registration */
- SetWindowLongPtrW(hWnd, GWLP_USERDATA, (DWORD_PTR)NULL);
-
return DefWindowProcW(hWnd, WM_NCDESTROY, 0, 0);
}