mirror of
https://gitlab.freedesktop.org/xorg/lib/libxcursor.git
synced 2026-05-06 03:28:06 +02: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
448398a3b9
commit
204b6f1308
1 changed files with 6 additions and 5 deletions
11
src/file.c
11
src/file.c
|
|
@ -161,11 +161,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…
Add table
Reference in a new issue