From 05a8209fa708db240d9e5134a05c3184ee80dfa1 Mon Sep 17 00:00:00 2001 From: rootkiller6788 <17553215+rootkiller6788@user.noreply.gitee.com> Date: Sat, 12 Sep 2026 23:48:01 +0800 Subject: [PATCH] lib/suitar: reset bIndex after flushing a full block Write left w.bIndex at 512 once a full block had been written out, so the next loop iteration took the "partial block" branch, copied zero bytes and went round again forever, writing the same 512 bytes over and over. Calling Write with sizes that aren't multiples of 512 is enough to hit this. It also duplicated the last data block when a Write call happened to end exactly on a block boundary, because flush then saw a non-zero bIndex and wrote the block out a second time. --- lib/suitar/suitar.go | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/suitar/suitar.go b/lib/suitar/suitar.go index 6055806c..9da6a16c 100644 --- a/lib/suitar/suitar.go +++ b/lib/suitar/suitar.go @@ -457,6 +457,7 @@ func (w *Writer) Write(b []byte) (int, error) { w.err = err break } + w.bIndex = 0 } if tooMuch && (w.err == nil) {