From a9e1d86374f3bf2e76efc86804a7cc3250992391 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Tue, 28 Mar 2023 12:41:20 +0200 Subject: [PATCH] zstd: Fix fallback on incompressible block Regresssion from #792 (unreleased) --- zstd/blockenc.go | 3 ++- zstd/testdata/fuzz/encode-corpus-encoded.zip | Bin 1624058 -> 1624741 bytes 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/zstd/blockenc.go b/zstd/blockenc.go index 966897c1fa..fd4a36f730 100644 --- a/zstd/blockenc.go +++ b/zstd/blockenc.go @@ -782,7 +782,8 @@ func (b *blockEnc) encode(org []byte, raw, rawAllLits bool) error { // Maybe even add a bigger margin. if len(b.output)-3-bhOffset >= b.size { // Discard and encode as raw block. - b.encodeRaw(org) + b.output = b.encodeRawTo(b.output[:bhOffset], org) + b.popOffsets() b.litEnc.Reuse = huff0.ReusePolicyNone return nil } diff --git a/zstd/testdata/fuzz/encode-corpus-encoded.zip b/zstd/testdata/fuzz/encode-corpus-encoded.zip index aa75c2d32883c445f0ec95069659e40a3a6d95c4..87bbb78a700aac5005ab17fac020f2f7e89f9d31 100644 GIT binary patch delta 773 zcmey>pS*NxazhJa3sVbo3rh=Y3tJ0&3r7oQ3s(zw3r`Dg3ttO=i$IHDi%^Sji%5%T zi`W+NI~w)OEFug{3>*x*;%dV3P6(FWXJlZQ#LU3pz`(#@nU-i^VU%o|nrvoZn38Ie zYL=F2Vs4RS3=~TpDv!LxgXJ?yR)C_dRg4gzB&i{0< zxlm`$reEKmJ~eQ3y7WLWr>e2|KxM(Y=^8KZGu(N`tj1Za_w27l*`aAqoa+ds6p8cmPENj(aer^tzh_cr?RBv!^5uak?{BzV zJ?i!5U9R1Rx~XkFk=t@6PR+M_z%Ikly)sa2T3YDa^Lg+7u(sdQ5Z``FLxN|1JtLC{ q1Maj0Oim1p3<^LJsDt8^72wUv1~Tyq^A+Zb`HT$W+Ty@8%K!iplt%Ud delta 86 zcmZ2FHThS6azhJa3sVbo3rh=Y3tJ0&3r7oQ3s(zw3r`Dg3ttO=i$IHDi%^Sji%5%T ni`W+NI~whh+Tz