Skip to content

tiny_jpeg.h: Fix left shift int UB warning#729

Merged
sezero merged 1 commit intolibsdl-org:mainfrom
Sackzement:tiny_jpeg_int_shift
Apr 21, 2026
Merged

tiny_jpeg.h: Fix left shift int UB warning#729
sezero merged 1 commit intolibsdl-org:mainfrom
Sackzement:tiny_jpeg_int_shift

Conversation

@Sackzement
Copy link
Copy Markdown
Contributor

Warning:

SDL3_image/src/tiny_jpeg.h:631:35: runtime error: left shift of 126 by 25 places cannot be represented in type 'int'

*bitbuffer |= (uint32_t)(bits << (32 - nloc));

Warning reason

Variable bits is promoted to int, then shifted and the sign-bit is written to.

Changes:

Casting the variable bits to uint32_t before the shift.

@sezero sezero merged commit 5abcc77 into libsdl-org:main Apr 21, 2026
5 checks passed
@Sackzement Sackzement deleted the tiny_jpeg_int_shift branch April 21, 2026 15:17
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