Skip to content

Fixed UB on OS X#6

Open
H2CO3 wants to merge 1 commit intoflugi:masterfrom
H2CO3:patch-4
Open

Fixed UB on OS X#6
H2CO3 wants to merge 1 commit intoflugi:masterfrom
H2CO3:patch-4

Conversation

@H2CO3
Copy link

@H2CO3 H2CO3 commented Mar 1, 2014

Since - for some reason - OS X needs the blue color component to be shifted by 24 to the left, and int is 32 bits wide on OS X, using any color of which the blue component is greater than 127 results in shifting a 1 to the sign bit of an int, which invokes undefined behavior. This commit fixes that by declaring draw_clr as an unsigned integer.

Since - for some reason - OS X needs the red color component to be shifted by 24 to the left, and `int` is 32 bits wide on OS X, using any color of which the red component is greater than 127 results in shifting a `1` to the sign bit of a signed `int`, which results in undefined behavior. This commit fixes that by declaring `draw_clr` as an `unsigned` integer.
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.

1 participant