From 77f4ff1cfd78ebac99a4f5f87d49227bd6c2b60d Mon Sep 17 00:00:00 2001 From: Seebs Date: Mon, 29 Mar 2021 12:22:22 -0500 Subject: [PATCH] fix bitmap.BitwiseEqual bugs bitmap.BitwiseEqual had a couple of subtle bugs, and the net result is that if the bitmap you were comparing to had an empty container after the original bitmap ran out of containers, we'd spuriously report the container as existing and being... the last container in the original, actually. Issues are both that we were grabbing the value from the wrong iterator, and also that we were iterating twice per loop, and thus could also have missed a non-empty container immediately following an empty one. --- roaring/roaring.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/roaring/roaring.go b/roaring/roaring.go index 9c3a97aa9..d5ec88712 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -6470,16 +6470,14 @@ func (b *Bitmap) BitwiseEqual(c *Bitmap) (bool, error) { bct++ break } - bn = biter.Next() } for cn { cn = citer.Next() - ck, cc = biter.Value() + ck, cc = citer.Value() if cc.N() != 0 { cct++ break } - cn = biter.Next() } if bn { return false, fmt.Errorf("container mismatch: %d vs %d containers, first bitmap has extra container %d [%v bits]", bct, cct, bk, bc)