diff options
author | 6543 <6543@obermui.de> | 2020-02-28 00:10:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-27 20:10:27 -0300 |
commit | e57ac841de1fc93df15ba8bef280077bbb733bf1 (patch) | |
tree | d81462a68ee6ae6276ae14ef0b3ccc7c0d77ada7 /routers/repo/attachment.go | |
parent | 15fbf509d3475cef3f8a7e994b59e4d78fd1c508 (diff) | |
download | gitea-e57ac841de1fc93df15ba8bef280077bbb733bf1.tar.gz gitea-e57ac841de1fc93df15ba8bef280077bbb733bf1.zip |
Fix potential bugs (#10513)
* use e if it is an option
* potential nil so check err first
* check err first
* m == nil already checked
Diffstat (limited to 'routers/repo/attachment.go')
-rw-r--r-- | routers/repo/attachment.go | 8 |
1 files changed, 4 insertions, 4 deletions
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)) |