From 8c5bae9428c757890f84fdfcf7c6b2af3ca53136 Mon Sep 17 00:00:00 2001 From: Will Johnson Date: Mon, 29 Jan 2024 13:11:27 -0500 Subject: [PATCH] Use io.ReadFull in roaring64.Bitmap.ReadFrom. --- roaring64/roaring64.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roaring64/roaring64.go b/roaring64/roaring64.go index 935477bc..9e7f6b7f 100644 --- a/roaring64/roaring64.go +++ b/roaring64/roaring64.go @@ -135,8 +135,8 @@ func (rb *Bitmap) FromUnsafeBytes(data []byte) (p int64, err error) { func (rb *Bitmap) ReadFrom(stream io.Reader) (p int64, err error) { sizeBuf := make([]byte, 8) var n int - n, err = stream.Read(sizeBuf) - if n == 0 || err != nil { + n, err = io.ReadFull(stream, sizeBuf) + if err != nil { return int64(n), err } p += int64(n) @@ -159,8 +159,8 @@ func (rb *Bitmap) ReadFrom(stream io.Reader) (p int64, err error) { } keyBuf := sizeBuf[:4] for i := uint64(0); i < size; i++ { - n, err = stream.Read(keyBuf) - if n == 0 || err != nil { + n, err = io.ReadFull(stream, keyBuf) + if err != nil { return int64(n), fmt.Errorf("error in bitmap.readFrom: could not read key #%d: %s", i, err) } p += int64(n)