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 <tsogomonian@astralinux.ru>
This commit is contained in:
Tigran Sogomonian 2024-10-15 17:00:47 +03:00
parent 1dcb4c58c2
commit c05987ddd3
1 changed files with 1 additions and 1 deletions

View File

@ -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
}