-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when window width and height are too high (#1134)
## Summary of the Pull Request Currently, the program crashes with a window width or height greater than 32767 (accounting for window decorations). This can be caused when the `initialRows` and `initialColumns` settings are set too high (also depends on the font width and height). This fixes the issue by not allowing the window to expand beyond 32767x32767. ## References #843 - relocated the ClampToShortMax helper for reuse elsewhere
- Loading branch information
Showing
7 changed files
with
79 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "precomp.h" | ||
#include "WexTestClass.h" | ||
#include "..\..\inc\consoletaeftemplates.hpp" | ||
|
||
#include "..\inc\utils.hpp" | ||
|
||
using namespace WEX::Common; | ||
using namespace WEX::Logging; | ||
using namespace WEX::TestExecution; | ||
|
||
using namespace Microsoft::Console::Utils; | ||
|
||
class UtilsTests | ||
{ | ||
TEST_CLASS(UtilsTests); | ||
|
||
TEST_METHOD(TestClampToShortMax) | ||
{ | ||
const short min = 1; | ||
|
||
// Test outside the lower end of the range | ||
const short minExpected = min; | ||
auto minActual = ClampToShortMax(0, min); | ||
VERIFY_ARE_EQUAL(minExpected, minActual); | ||
|
||
// Test negative numbers | ||
const short negativeExpected = min; | ||
auto negativeActual = ClampToShortMax(-1, min); | ||
VERIFY_ARE_EQUAL(negativeExpected, negativeActual); | ||
|
||
// Test outside the upper end of the range | ||
const short maxExpected = SHRT_MAX; | ||
auto maxActual = ClampToShortMax(50000, min); | ||
VERIFY_ARE_EQUAL(maxExpected, maxActual); | ||
|
||
// Test within the range | ||
const short withinRangeExpected = 100; | ||
auto withinRangeActual = ClampToShortMax(withinRangeExpected, min); | ||
VERIFY_ARE_EQUAL(withinRangeExpected, withinRangeActual); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters