C26451, promote before arithmetic if storing in larger result size (or use safe math)

This commit is contained in:
Michael Niksa
2019-08-29 13:41:51 -07:00
parent 50e2d0c433
commit 8579d8905a
6 changed files with 24 additions and 19 deletions

View File

@@ -569,7 +569,7 @@ IFACEMETHODIMP UiaTextRangeBase::GetText(_In_ int maxLength, _Out_ BSTR* pRetVal
if (currentScreenInfoRow == endScreenInfoRow)
{
// prevent the end from going past the last non-whitespace char in the row
endIndex = std::min(static_cast<size_t>(endColumn + 1), rowRight);
endIndex = std::min(gsl::narrow_cast<size_t>(endColumn) + 1, rowRight);
}
// if startIndex >= endIndex then _start is
@@ -1457,11 +1457,11 @@ std::pair<Endpoint, Endpoint> UiaTextRangeBase::_moveByCharacterForward(IUiaData
// check if we're at the edge of the screen info buffer
if (currentScreenInfoRow == moveState.LimitingRow &&
currentColumn + 1 >= right)
gsl::narrow_cast<size_t>(currentColumn) + 1 >= right)
{
break;
}
else if (currentColumn + 1 >= right)
else if (gsl::narrow_cast<size_t>(currentColumn) + 1 >= right)
{
// we're at the edge of a row and need to go to the next one
currentColumn = moveState.FirstColumnInRow;
@@ -1669,11 +1669,11 @@ UiaTextRangeBase::_moveEndpointByUnitCharacterForward(IUiaData* pData,
// check if we're at the edge of the screen info buffer
if (currentScreenInfoRow == moveState.LimitingRow &&
currentColumn + 1 >= right)
gsl::narrow_cast<size_t>(currentColumn) + 1 >= right)
{
break;
}
else if (currentColumn + 1 >= right)
else if (gsl::narrow_cast<size_t>(currentColumn) + 1 >= right)
{
// we're at the edge of a row and need to go to the next one
currentColumn = moveState.FirstColumnInRow;