Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash when calling SetConsoleScreenBufferSize in conpty #4021

Merged
merged 2 commits into from
Dec 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/host/getset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down