nnn

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit fb5b2e5e649cf1a05813f44b466a613e697404fc
parent c9b384f00904caa7545a366b8e00efeb17486977
Author: NRK <nrk@disroot.org>
Date:   Tue,  3 Jan 2023 02:20:21 +0600

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

Diffstat:
Msrc/icons-hash.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/icons-hash.c b/src/icons-hash.c @@ -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