Skip to content

Commit

Permalink
Fix regression
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed May 3, 2024
1 parent a4946c8 commit 78c20d4
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions v2/transform/ROLZCodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,12 +658,6 @@ func (this *rolzCodec1) Inverse(src, dst []byte) (uint, uint, error) {
}
}

is := internal.NewBufferStream(make([]byte, 0, len(src)))

if _, err := is.Write(src[5:]); err != nil {
return 0, 0, err
}

// Main loop
for startChunk < dstEnd {
mIdx := 0
Expand All @@ -687,6 +681,7 @@ func (this *rolzCodec1) Inverse(src, dst []byte) (uint, uint, error) {
// Scope to deallocate resources early
{
// Decode literal, match length and match index buffers
is := internal.NewBufferStream(src[srcIdx:])
var ibs kanzi.InputBitStream

if ibs, err = bitstream.NewDefaultInputBitStream(is, 65536); err != nil {
Expand All @@ -699,22 +694,22 @@ func (this *rolzCodec1) Inverse(src, dst []byte) (uint, uint, error) {
mIdxLen := int(ibs.ReadBits(32))

if litLen < 0 || litLen > sizeChunk {
err = fmt.Errorf("ROLZ codec: Invalid length: got %d, must be less than or equal to %v", litLen, sizeChunk)
err = fmt.Errorf("ROLZ codec: Invalid length for literals: got %d, must be less than or equal to %d", litLen, sizeChunk)
goto End
}

if tkLen < 0 || tkLen > sizeChunk {
err = fmt.Errorf("ROLZ codec: Invalid length: got %d, must be less than or equal to %v", tkLen, sizeChunk)
err = fmt.Errorf("ROLZ codec: Invalid length for tokens: got %d, must be less than or equal to %d", tkLen, sizeChunk)
goto End
}

if mLenLen < 0 || mLenLen > sizeChunk {
err = fmt.Errorf("ROLZ codec: Invalid length: got %d, must be less than or equal to %v", mLenLen, sizeChunk)
err = fmt.Errorf("ROLZ codec: Invalid length for matches: got %d, must be less than or equal to %d", mLenLen, sizeChunk)
goto End
}

if mIdxLen < 0 || mIdxLen > sizeChunk {
err = fmt.Errorf("ROLZ codec: Invalid length: got %d, must be less than or equal to %v", mIdxLen, sizeChunk)
err = fmt.Errorf("ROLZ codec: Invalid length for match indexes: got %d, must be less than or equal to %d", mIdxLen, sizeChunk)
goto End
}

Expand Down

0 comments on commit 78c20d4

Please sign in to comment.