From e57ac841de1fc93df15ba8bef280077bbb733bf1 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 28 Feb 2020 00:10:27 +0100 Subject: Fix potential bugs (#10513) * use e if it is an option * potential nil so check err first * check err first * m == nil already checked --- routers/repo/attachment.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'routers/repo/attachment.go') diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 96dc28a23a..f938c230ed 100644 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -70,14 +70,14 @@ func UploadAttachment(ctx *context.Context) { func DeleteAttachment(ctx *context.Context) { file := ctx.Query("file") attach, err := models.GetAttachmentByUUID(file) - if !ctx.IsSigned || (ctx.User.ID != attach.UploaderID) { - ctx.Error(403) - return - } if err != nil { ctx.Error(400, err.Error()) return } + if !ctx.IsSigned || (ctx.User.ID != attach.UploaderID) { + ctx.Error(403) + return + } err = models.DeleteAttachment(attach, true) if err != nil { ctx.Error(500, fmt.Sprintf("DeleteAttachment: %v", err)) -- cgit v1.2.3