From cb8cab7b0304b72393ea3a8db755077b1286a686 Mon Sep 17 00:00:00 2001 From: Olivier Brunel Date: Mon, 1 Jan 2024 20:34:05 +0100 Subject: Fix bitarray_not when within a single byte Notably when a=0 (i.e. start on the first bit) it would affect the entire byte (all 8 bits). Signed-off-by: Olivier Brunel --- src/libstddjb/bitarray_not.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstddjb') diff --git a/src/libstddjb/bitarray_not.c b/src/libstddjb/bitarray_not.c index 6c4149e..1e9f5af 100644 --- a/src/libstddjb/bitarray_not.c +++ b/src/libstddjb/bitarray_not.c @@ -7,7 +7,7 @@ void bitarray_not (unsigned char *s, size_t a, size_t b) if (!b) return ; b += a ; if ((a >> 3) == ((b-1) >> 3)) - s[a>>3] ^= ((1 << (a & 7)) - 1) ^ ((a << (b & 7)) - 1) ; + s[a>>3] ^= ((1 << (a & 7)) - 1) ^ ((1 << (1 + (b-1 & 7))) - 1) ; else { size_t i = (a>>3) + 1 ; -- cgit v1.2.3