From a0df376348d2ad1d3e557ea221e75c78a5d9fd96 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 17 Dec 2022 12:12:05 +0100 Subject: pkg/image: make Decompress easier to use Change DecompressWriter to DecompressCheck: checking validity of the image is the only useful use of DecompressWriter. Change Decompress to MustDecompress which does not return an error. We check validity during program deserialization, so all other uses already panic on errors. Also add dtor return value in preparation for subsequent changes. --- prog/encoding.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'prog/encoding.go') diff --git a/prog/encoding.go b/prog/encoding.go index bfa80b983..bd2efb836 100644 --- a/prog/encoding.go +++ b/prog/encoding.go @@ -7,7 +7,6 @@ import ( "bytes" "encoding/hex" "fmt" - "io/ioutil" "reflect" "strconv" "strings" @@ -606,7 +605,7 @@ func (p *parser) parseArgString(t Type, dir Dir) (Arg, error) { } // Check compressed data for validity. if typ.IsCompressed() { - if err := image.DecompressWriter(ioutil.Discard, data); err != nil { + if err := image.DecompressCheck(data); err != nil { p.strictFailf("invalid compressed data in arg: %v", err) // In non-strict mode, empty the data slice. data = image.Compress(nil) -- cgit mrf-deployment