From e34004ce5e701cad0010ed519398b3dd035d9251 Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Sat, 10 Oct 2026 19:03:38 +0200 Subject: [PATCH] fix: close image file handle --- api/application.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/api/application.go b/api/application.go index 612c20c60..90ced9239 100644 --- a/api/application.go +++ b/api/application.go @@ -3,6 +3,7 @@ package api import ( "errors" "fmt" + "io" "net/http" "os" "path/filepath" @@ -421,8 +422,16 @@ func (a *ApplicationAPI) UploadApplicationImage(ctx *gin.Context) { return } head := make([]byte, 261) - open, _ := file.Open() - open.Read(head) + open, err := file.Open() + if err != nil { + ctx.AbortWithError(500, err) + return + } + defer open.Close() + if _, err := open.Read(head); err != nil && err != io.EOF { + ctx.AbortWithError(500, err) + return + } if !filetype.IsImage(head) { ctx.AbortWithError(400, errors.New("file must be an image")) return