mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 00:48:23 -06:00
Multiple fixes to address DD CodeQL requirements (#18451)
After taking in 1.22, our CodeQL process caught a few locations where we weren't following the right guidance: - Performing integer comparisons of different sizes which could lead to an infinite loop if the larger integer goes out of range of the smaller integer - Not checking HResult of a called method Co-authored-by: aphistra <102989060+aphistra@users.noreply.github.com>
This commit is contained in:
parent
a86c90a045
commit
6e89242373
@ -431,7 +431,7 @@ OutputCellIterator ROW::WriteCells(OutputCellIterator it, const til::CoordType c
|
||||
THROW_HR_IF(E_INVALIDARG, limitRight.value_or(0) >= size());
|
||||
|
||||
// If we're given a right-side column limit, use it. Otherwise, the write limit is the final column index available in the char row.
|
||||
const auto finalColumnInRow = limitRight.value_or(size() - 1);
|
||||
const auto finalColumnInRow = gsl::narrow_cast<uint16_t>(limitRight.value_or(size() - 1));
|
||||
|
||||
auto currentColor = it->TextAttr();
|
||||
uint16_t colorUses = 0;
|
||||
|
||||
@ -574,7 +574,8 @@ try
|
||||
}
|
||||
|
||||
const auto cpt = gsl::narrow_cast<DWORD>(points.size());
|
||||
return PolyBezier(_hdcMemoryContext, points.data(), cpt);
|
||||
RETURN_HR_IF(E_FAIL, !PolyBezier(_hdcMemoryContext, points.data(), cpt));
|
||||
return S_OK;
|
||||
};
|
||||
|
||||
if (lines.test(GridLines::Left))
|
||||
|
||||
@ -610,7 +610,7 @@ void SixelParser::_updateTextColors()
|
||||
// the text output as well.
|
||||
if (_conformanceLevel <= 3 && _maxColors > 2 && _colorTableChanged) [[unlikely]]
|
||||
{
|
||||
for (IndexType tableIndex = 0; tableIndex < _maxColors; tableIndex++)
|
||||
for (IndexType tableIndex = 0; _maxColors <= 16 && tableIndex < _maxColors; tableIndex++)
|
||||
{
|
||||
_dispatcher.SetColorTableEntry(tableIndex, _colorFromIndex(tableIndex));
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ namespace Microsoft::Console::VirtualTerminal
|
||||
public:
|
||||
constexpr CharSet(const std::initializer_list<std::pair<wchar_t, wchar_t>> replacements)
|
||||
{
|
||||
for (auto i = L'\0'; i < _translationTable.size(); i++)
|
||||
for (auto i = L'\0'; i < gsl::narrow_cast<wchar_t>(_translationTable.size()); i++)
|
||||
_translationTable.at(i) = BaseChar + i;
|
||||
for (auto replacement : replacements)
|
||||
_translationTable.at(replacement.first - BaseChar) = replacement.second;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user