Skip to content

Commit

Permalink
Fix sixel crash when buffer is reflowed.
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed Sep 22, 2024
1 parent a7e47b7 commit 4632707
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/terminal/adapter/SixelParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,16 @@ void SixelParser::_eraseImageBufferRows(const int rowCount, const til::CoordType
const auto pixelCount = rowCount * _cellSize.height;
const auto bufferOffset = rowOffset * _cellSize.height * _imageMaxWidth;
const auto bufferOffsetEnd = bufferOffset + pixelCount * _imageMaxWidth;
_imageBuffer.erase(_imageBuffer.begin() + bufferOffset, _imageBuffer.begin() + bufferOffsetEnd);
_imageCursor.y -= pixelCount;
if (static_cast<size_t>(bufferOffsetEnd) >= _imageBuffer.size()) [[unlikely]]
{
_imageBuffer.clear();
_imageCursor.y = 0;
}
else
{
_imageBuffer.erase(_imageBuffer.begin() + bufferOffset, _imageBuffer.begin() + bufferOffsetEnd);
_imageCursor.y -= pixelCount;
}
}

void SixelParser::_maybeFlushImageBuffer(const bool endOfSequence)
Expand Down

0 comments on commit 4632707

Please sign in to comment.