mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
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.
This commit is contained in:
parent
8b744412aa
commit
65abd4e92a
1 changed files with 6 additions and 5 deletions
|
@ -285,11 +285,12 @@ _XcursorReadUInt (XcursorFile *file, XcursorUInt *u)
|
|||
return XcursorFalse;
|
||||
|
||||
if ((*file->read) (file, bytes, 4) != 4)
|
||||
return XcursorFalse;
|
||||
*u = ((bytes[0] << 0) |
|
||||
(bytes[1] << 8) |
|
||||
(bytes[2] << 16) |
|
||||
(bytes[3] << 24));
|
||||
return XcursorFalse;
|
||||
|
||||
*u = ((XcursorUInt)(bytes[0]) << 0) |
|
||||
((XcursorUInt)(bytes[1]) << 8) |
|
||||
((XcursorUInt)(bytes[2]) << 16) |
|
||||
((XcursorUInt)(bytes[3]) << 24);
|
||||
return XcursorTrue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue