1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-26 03:18:28 +00:00

Fix potential bugs (#10513) (#10518)

* use e if it is an option
* potential nil so check err first
* check err first
* m == nil already checked
This commit is contained in:
6543
2020-02-28 04:12:23 +01:00
committed by GitHub
parent c6b78c3d31
commit 11300ee582
6 changed files with 13 additions and 9 deletions

View File

@@ -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))

View File

@@ -237,11 +237,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