From 1d850790fb23a8d88b7ab6913599b3330ab3566a Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 15 Jan 2026 18:23:40 -0500 Subject: [PATCH] run serialization should not be used if there is no run --- roaringarray.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/roaringarray.go b/roaringarray.go index 31638d4b..df8d2ca1 100644 --- a/roaringarray.go +++ b/roaringarray.go @@ -596,6 +596,17 @@ func (ra *roaringArray) readFrom(stream internal.ByteInput, cookieHeader ...byte if err != nil { return stream.GetReadBytes(), fmt.Errorf("malformed bitmap, failed to read is-run bitmap, got: %s", err) } + isAllZero := true + for i := 0; i < isRunBitmapSize; i++ { + if isRunBitmap[i] != 0 { + isAllZero = false + break + } + } + if isAllZero { + return stream.GetReadBytes(), fmt.Errorf("malformed bitmap, is-run bitmap cannot be all zero") + } + } else if cookie == serialCookieNoRunContainer { size, err = stream.ReadUInt32() if err != nil {