Skip to content

Commit

Permalink
fix panic handler in NewCompressor (ledgerwatch#987)
Browse files Browse the repository at this point in the history
currently if newdecompressor panics, it will return nil, nil

this should make it return an error instead
  • Loading branch information
elee1766 authored and calmbeing committed Jul 12, 2023
1 parent 3ba9061 commit d6705bb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions compress/decompress.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,12 @@ func SetDecompressionTableCondensity(fromBitSize int) {
condensePatternTableBitThreshold = fromBitSize
}

func NewDecompressor(compressedFilePath string) (*Decompressor, error) {
func NewDecompressor(compressedFilePath string) (d *Decompressor, err error) {
_, fName := filepath.Split(compressedFilePath)
d := &Decompressor{
d = &Decompressor{
filePath: compressedFilePath,
fileName: fName,
}
var err error
defer func() {
if rec := recover(); rec != nil {
err = fmt.Errorf("decompressing file: %s, %+v, trace: %s", compressedFilePath, rec, dbg.Stack())
Expand Down

0 comments on commit d6705bb

Please sign in to comment.