From c05987ddd3d0e92e7ca793b8fec6d6eb07fc0b80 Mon Sep 17 00:00:00 2001 From: Tigran Sogomonian Date: Tue, 15 Oct 2024 17:00:47 +0300 Subject: [PATCH] api: Replace close function in condition body The close is replaced in the body of the error condition. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Tigran Sogomonian --- pkg/api/handlers/libpod/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go index 26b899f002..6b5e5abb31 100644 --- a/pkg/api/handlers/libpod/images.go +++ b/pkg/api/handlers/libpod/images.go @@ -403,10 +403,10 @@ func ImagesImport(w http.ResponseWriter, r *http.Request) { return } defer os.Remove(tmpfile.Name()) - defer tmpfile.Close() if _, err := io.Copy(tmpfile, r.Body); err != nil && err != io.EOF { utils.Error(w, http.StatusInternalServerError, fmt.Errorf("unable to write archive to temporary file: %w", err)) + tmpfile.Close() return }