mirror of
https://github.com/jarun/nnn.git
synced 2024-09-11 13:06:14 +03:00
icons-hash: fix bitwise rotation
in case the rotation is 0, `v >> (32 - r)` would end up doing a 32 right shift which is equal to the width of `v` and thus undefined behavior. ref: https://blog.regehr.org/archives/1063
This commit is contained in:
parent
c9b384f009
commit
fb5b2e5e64
@ -109,7 +109,7 @@ pcg(uint64_t *state)
|
||||
*state *= GOLDEN_RATIO_64;
|
||||
uint32_t r = (oldstate >> 59);
|
||||
uint32_t v = (oldstate ^ (oldstate >> 18)) >> 27;
|
||||
return (v >> (32 - r)) | (v << r);
|
||||
return (v >> (-r & 31)) | (v << r);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user