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 | |
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')
-rw-r--r-- | routers/repo/attachment.go | 8 | ||||
-rw-r--r-- | routers/repo/commit.go | 2 |
2 files changed, 5 insertions, 5 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)) diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 2767986fda..77439f8873 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -244,11 +244,11 @@ func Diff(ctx *context.Context) { parents := make([]string, commit.ParentCount()) for i := 0; i < commit.ParentCount(); i++ { sha, err := commit.ParentID(i) - parents[i] = sha.String() if err != nil { ctx.NotFound("repo.Diff", err) return } + parents[i] = sha.String() } ctx.Data["CommitID"] = commitID |