-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed size comparisons that could lead to infinite loops #18451
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -610,7 +610,9 @@ void SixelParser::_updateTextColors() | |
// the text output as well. | ||
if (_conformanceLevel <= 3 && _maxColors > 2 && _colorTableChanged) [[unlikely]] | ||
{ | ||
for (IndexType tableIndex = 0; tableIndex < _maxColors; tableIndex++) | ||
// _maxColors is 64-bit and tableIndex is 8-bit. If _maxColors is higher | ||
// than the 8-bit integer limit, we will loop indefinitely. | ||
for (IndexType tableIndex = 0; tableIndex < (saturated_cast<uint8_t>(_maxColors)); tableIndex++) | ||
Comment on lines
611
to
+615
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this situation |
||
{ | ||
_dispatcher.SetColorTableEntry(tableIndex, _colorFromIndex(tableIndex)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not tested this, but looking at just the code, it seems to me that simply removing the
narrow_cast
above would have the same effect of fixing this bug.