mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 21:36:42 +00: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;
|
*state *= GOLDEN_RATIO_64;
|
||||||
uint32_t r = (oldstate >> 59);
|
uint32_t r = (oldstate >> 59);
|
||||||
uint32_t v = (oldstate ^ (oldstate >> 18)) >> 27;
|
uint32_t v = (oldstate ^ (oldstate >> 18)) >> 27;
|
||||||
return (v >> (32 - r)) | (v << r);
|
return (v >> (-r & 31)) | (v << r);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue