pan/decode: Avoid undefined behaviour on shift in bits()
v2: Return 0 instead of `word` (Alyssa) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11869>
This commit is contained in:
parent
6642749458
commit
04c02418d7
|
@ -451,6 +451,9 @@ bits(u32 word, u32 lo, u32 hi)
|
|||
if (hi - lo >= 32)
|
||||
return word; // avoid undefined behavior with the shift
|
||||
|
||||
if (lo >= 32)
|
||||
return 0;
|
||||
|
||||
return (word >> lo) & ((1 << (hi - lo)) - 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue