about summary refs log tree commit diff
path: root/src/libstddjb
diff options
context:
space:
mode:
authorOlivier Brunel <jjk@jjacky.com>2024-01-01 20:34:05 +0100
committerLaurent Bercot <ska-skaware@skarnet.org>2024-01-02 02:05:02 +0000
commitcb8cab7b0304b72393ea3a8db755077b1286a686 (patch)
tree2ac21c36b8664a20b846aae4d4890d8a57dee5d3 /src/libstddjb
parent86e231a8dfcd1e032bda5f927214bf385222ff02 (diff)
downloadskalibs-cb8cab7b0304b72393ea3a8db755077b1286a686.tar.gz
skalibs-cb8cab7b0304b72393ea3a8db755077b1286a686.tar.xz
skalibs-cb8cab7b0304b72393ea3a8db755077b1286a686.zip
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 <jjk@jjacky.com>
Diffstat (limited to 'src/libstddjb')
-rw-r--r--src/libstddjb/bitarray_not.c2
1 files changed, 1 insertions, 1 deletions
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 ;