]> source.dussan.org Git - gitea.git/commitdiff
Validate Issue Index before querying DB (#16406)
authorNorwin <noerw@users.noreply.github.com>
Mon, 12 Jul 2021 20:22:27 +0000 (20:22 +0000)
committerGitHub <noreply@github.com>
Mon, 12 Jul 2021 20:22:27 +0000 (16:22 -0400)
models/issue.go

index b9643ae00ec42370fca13c56c06cadbcf5920d2d..225dfee20f0956269221a7ed3d1a6546ecc0d333 100644 (file)
@@ -1018,6 +1018,9 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
 
 // GetIssueByIndex returns raw issue without loading attributes by index in a repository.
 func GetIssueByIndex(repoID, index int64) (*Issue, error) {
+       if index < 1 {
+               return nil, ErrIssueNotExist{}
+       }
        issue := &Issue{
                RepoID: repoID,
                Index:  index,