Skip to content

Commit 0af275b

Browse files
let's not let pops take us below zero
1 parent 0e478e5 commit 0af275b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/cascadia/TerminalCore/TerminalApi.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ bool Terminal::PushGraphicsRendition(const ::Microsoft::Console::VirtualTerminal
262262
else
263263
{
264264
// Save everything.
265-
if ((_numSgrPushes < _countof(_storedSgrAttributes)) && (_numSgrPushes >= 0))
265+
if (_numSgrPushes < _countof(_storedSgrAttributes))
266266
{
267267
_storedSgrAttributes[_numSgrPushes] = _buffer->GetCurrentAttributes();
268268
}
@@ -275,11 +275,14 @@ bool Terminal::PushGraphicsRendition(const ::Microsoft::Console::VirtualTerminal
275275

276276
bool Terminal::PopGraphicsRendition()
277277
{
278-
_numSgrPushes--;
279-
280-
if ((_numSgrPushes < _countof(_storedSgrAttributes)) && (_numSgrPushes >= 0))
278+
if (_numSgrPushes > 0)
281279
{
282-
_buffer->SetCurrentAttributes(_storedSgrAttributes[_numSgrPushes]);
280+
_numSgrPushes--;
281+
282+
if (_numSgrPushes < _countof(_storedSgrAttributes))
283+
{
284+
_buffer->SetCurrentAttributes(_storedSgrAttributes[_numSgrPushes]);
285+
}
283286
}
284287

285288
return true;

0 commit comments

Comments
 (0)