cp: close temporary file on error path

follow-up for https://github.com/containers/podman/pull/19526

on io.Copy() errors make sure the temporary file is closed.

[NO NEW TESTS NEEDED]

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2023-08-07 12:39:20 +02:00
parent c04ead152e
commit 39641482c1
No known key found for this signature in database
GPG Key ID: 67E38F7A8BA21772
1 changed files with 1 additions and 0 deletions

View File

@ -386,6 +386,7 @@ func copyToContainer(container string, containerPath string, hostPath string) er
_, err = io.Copy(tmpFile, os.Stdin)
if err != nil {
_ = tmpFile.Close()
return err
}
if err = tmpFile.Close(); err != nil {