api: Add error check

Add error check during tmpfile close.

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-11-07 14:53:15 +03:00
parent c05987ddd3
commit 9f5bbecb95
1 changed files with 4 additions and 1 deletions

View File

@ -410,7 +410,10 @@ func ImagesImport(w http.ResponseWriter, r *http.Request) {
return
}
tmpfile.Close()
if err := tmpfile.Close(); err != nil {
utils.Error(w, http.StatusInternalServerError, fmt.Errorf("unable to close tempfile: %w", err))
return
}
source = tmpfile.Name()
}