Skip to content

Fix undefined behavior

Valentin requested to merge e00E/wayland:fix-undefined-behavior into master

Copy of https://github.com/swaywm/wlroots/pull/2385 and xorg/lib/libxcursor!2 (merged) .

Use fixed size integer type

This type is meant to be 4 bytes large as seen in _XcursorReadUInt which always reads 4 bytes. An unsigned int is often 4 bytes large but this isnt' guaranteed so it is cleaner to use the exact type we want.

Fix undefined behavior

Without the casts the bytes accesses get converted to int. but int is not guaranteed to be 4 bytes large. Even when it is 4 bytes large bytes[3] << 24 does not fit because int is signed.

Edited by Valentin

Merge request reports