Skip to content

Commit 440aecf

Browse files
committed
Fix math and shift overflow in function visual_color_to_uint32
Clang said: > [..]/libvisual/lv_color.c:263:16: error: signed shift result (0x100000000) requires 34 bits to represent, but 'int' only has 32 bits [-Werror,-Wshift-overflow] > colors = (256 << 24) | > ~~~ ^ ~~ A closer look reveals that 255 (0xFF) is the maximum alpha value and that 256 (0x100) should have been 255 in the first place. Original report at https://sourceforge.net/p/libvisual/bugs/18/
1 parent 92d7143 commit 440aecf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libvisual/libvisual/lv_color.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ uint32_t visual_color_to_uint32 (VisColor *color)
260260

261261
visual_log_return_val_if_fail (color != NULL, 0);
262262

263-
colors = (256 << 24) |
263+
colors = (0xFF << 24) |
264264
(color->r << 16) |
265265
(color->g << 8) |
266266
(color->b);

0 commit comments

Comments
 (0)