Skip to content

Commit

Permalink
zstd_test.go: Fix TestCompressLevelStackCgoBug to actually crash
Browse files Browse the repository at this point in the history
This bug is very sensitive to stack sizes. Calling Decompress caused
that function to copy the stack, which then avoided the bug.
  • Loading branch information
evanj committed Feb 9, 2021
1 parent 36b22b9 commit 8f7b34a
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions zstd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,8 @@ func doCompressLevel(payload []byte, out []byte) error {
if err != nil {
return fmt.Errorf("failed calling CompressLevel: %w", err)
}

orig, err := Decompress(nil, out)
if err != nil {
return fmt.Errorf("failed calling Decompress: %w", err)
}
if !bytes.Equal(orig, payload) {
return fmt.Errorf("orig=%#v should match payload=%#v", string(orig), string(payload))
if len(out) == 0 {
return errors.New("CompressLevel must return non-empty bytes")
}
return nil
}
Expand Down

0 comments on commit 8f7b34a

Please sign in to comment.