Skip to content

Fixed comparison warnings#4551

Merged
hugovk merged 1 commit into
python-pillow:masterfrom
radarhere:warnings
Jun 20, 2020
Merged

Fixed comparison warnings#4551
hugovk merged 1 commit into
python-pillow:masterfrom
radarhere:warnings

Conversation

@radarhere

@radarhere radarhere commented Apr 13, 2020

Copy link
Copy Markdown
Member

Comment thread src/libImaging/Jpeg2KEncode.c Outdated
if (len) {
if (len > sizeof(params.tcp_rates) / sizeof(params.tcp_rates[0]))
if (len > 0) {
if ((unsigned)len > sizeof(params.tcp_rates) / sizeof(params.tcp_rates[0]))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

len comes from PySequence_Length, which can return -1 on failure. So if we change the condition to not just exclude empty sequence lengths, but also sequence lengths with errors, then the unsigned cast becomes safe to use.

@radarhere
radarhere force-pushed the warnings branch 2 times, most recently from 7e8c1c2 to 203f57e Compare April 26, 2020 02:23
@hugovk
hugovk merged commit 8e63260 into python-pillow:master Jun 20, 2020
@radarhere
radarhere deleted the warnings branch June 20, 2020 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants