浏览代码

Merge pull request #35589 from keloyang/close-fd

Close pipe in chrootarchive.invokeUnpack when cmd.Start()/json.NewEncoder failed
Tõnis Tiigi 7 年之前
父节点
当前提交
cefb33700c
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      pkg/chrootarchive/archive_unix.go

+ 2 - 0
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()