From 3611bc8bd204b7bf410af3bd18bfe2139dfa8d89 Mon Sep 17 00:00:00 2001 From: Norwin Date: Mon, 12 Jul 2021 20:22:27 +0000 Subject: [PATCH] Validate Issue Index before querying DB (#16406) --- models/issue.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/models/issue.go b/models/issue.go index b9643ae00ec42..225dfee20f095 100644 --- a/models/issue.go +++ b/models/issue.go @@ -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,