From 869666952196b09c1e1c78b75eb526d07e30ed54 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 19 Dec 2019 09:16:24 -0600 Subject: [PATCH] Fix a crash when calling SetConsoleScreenBufferSize in conpty --- src/host/getset.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/host/getset.cpp b/src/host/getset.cpp index dd9bb35a59f..6de3604371b 100644 --- a/src/host/getset.cpp +++ b/src/host/getset.cpp @@ -504,18 +504,18 @@ void ApiRoutines::GetLargestConsoleWindowSizeImpl(const SCREEN_INFORMATION& cont SCREEN_INFORMATION& screenInfo = context.GetActiveBuffer(); + // microsoft/terminal#3907 - We shouldn't resize the buffer to be + // smaller than the viewport. This was previously erroneously checked + // when the host was not in conpty mode. + RETURN_HR_IF(E_INVALIDARG, (size.X < screenInfo.GetViewport().Width() || size.Y < screenInfo.GetViewport().Height())); + // see MSFT:17415266 // We only really care about the minimum window size if we have a head. if (!ServiceLocator::LocateGlobals().IsHeadless()) { COORD const coordMin = screenInfo.GetMinWindowSizeInCharacters(); - // clang-format off // Make sure requested screen buffer size isn't smaller than the window. - RETURN_HR_IF(E_INVALIDARG, (size.X < screenInfo.GetViewport().Width() || - size.Y < screenInfo.GetViewport().Height() || - size.Y < coordMin.Y || - size.X < coordMin.X)); - // clang-format on + RETURN_HR_IF(E_INVALIDARG, (size.Y < coordMin.Y || size.X < coordMin.X)); } // Ensure the requested size isn't larger than we can handle in our data type.