From 52ebdfbe5db4b1444e245e41d0cb2c30c46703da Mon Sep 17 00:00:00 2001 From: y00316549 Date: Fri, 24 Nov 2017 13:41:08 +0800 Subject: [PATCH] Close pipe in chrootarchive.invokeUnpack when cmd.Start()/json.NewEncoder failed. Signed-off-by: y00316549 Upstream-commit: f5f8f008608e579e9164647910ef6f976e91e297 Component: engine --- components/engine/pkg/chrootarchive/archive_unix.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/engine/pkg/chrootarchive/archive_unix.go b/components/engine/pkg/chrootarchive/archive_unix.go index f2325abd74..75c010e98f 100644 --- a/components/engine/pkg/chrootarchive/archive_unix.go +++ b/components/engine/pkg/chrootarchive/archive_unix.go @@ -66,10 +66,12 @@ func invokeUnpack(decompressedArchive io.Reader, dest string, options *archive.T cmd.Stderr = output if err := cmd.Start(); err != nil { + w.Close() return fmt.Errorf("Untar error on re-exec cmd: %v", err) } //write the options to the pipe for the untar exec to read if err := json.NewEncoder(w).Encode(options); err != nil { + w.Close() return fmt.Errorf("Untar json encode to pipe failed: %v", err) } w.Close()