Clamp down DoSrvPrivateModifyLinesImpl to prevent overflowing during math with numerics library AND avoid setting scroll destination outside of the buffer.
This commit is contained in:
parent
62765f152e
commit
64f4de5067
|
@ -2057,13 +2057,18 @@ void DoSrvPrivateModifyLinesImpl(const size_t count, const bool insert)
|
|||
coordDestination.X = 0;
|
||||
if (insert)
|
||||
{
|
||||
coordDestination.Y = (cursorPosition.Y) + gsl::narrow<short>(count);
|
||||
coordDestination.Y = cursorPosition.Y + base::MakeClampedNum(count);
|
||||
}
|
||||
else
|
||||
{
|
||||
coordDestination.Y = (cursorPosition.Y) - gsl::narrow<short>(count);
|
||||
coordDestination.Y = (cursorPosition.Y) - base::MakeClampedNum(count);
|
||||
}
|
||||
|
||||
// The destination needs to still be inside the buffer.
|
||||
// We will take anything that is "too big" of a line modification and clamp it down to
|
||||
// the maximum modification that is possible in our buffer size.
|
||||
screenInfo.GetBufferSize().Clamp(coordDestination);
|
||||
|
||||
// Note the revealed lines are filled with the standard erase attributes.
|
||||
LOG_IF_FAILED(DoSrvPrivateScrollRegion(screenInfo,
|
||||
srScroll,
|
||||
|
|
|
@ -69,7 +69,10 @@
|
|||
#include <CppCoreCheck/Warnings.h>
|
||||
|
||||
// Chromium Numerics (safe math)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
#include <base/numerics/safe_math.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
// IntSafe
|
||||
#define ENABLE_INTSAFE_SIGNED_FUNCTIONS
|
||||
|
|
Loading…
Reference in a new issue