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.
master
Valentin 4 years ago committed by Simon Ser
parent 8b744412aa
commit 65abd4e92a

@ -286,10 +286,11 @@ _XcursorReadUInt (XcursorFile *file, XcursorUInt *u)
if ((*file->read) (file, bytes, 4) != 4) if ((*file->read) (file, bytes, 4) != 4)
return XcursorFalse; return XcursorFalse;
*u = ((bytes[0] << 0) |
(bytes[1] << 8) | *u = ((XcursorUInt)(bytes[0]) << 0) |
(bytes[2] << 16) | ((XcursorUInt)(bytes[1]) << 8) |
(bytes[3] << 24)); ((XcursorUInt)(bytes[2]) << 16) |
((XcursorUInt)(bytes[3]) << 24);
return XcursorTrue; return XcursorTrue;
} }

Loading…
Cancel
Save