Skip to content

Commit

Permalink
Check issue labels slice length before calling xorm Insert(go-gitea#2…
Browse files Browse the repository at this point in the history
…0655) (go-gitea#20836)

Backport go-gitea#20655

Fix go-gitea#20654

Co-authored-by: Gabriel Vasile <gabriel.vasile@email.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
  • Loading branch information
5 people authored Aug 17, 2022
1 parent 987798a commit b43d7e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions services/repository/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ func GenerateIssueLabels(ctx context.Context, templateRepo, generateRepo *repo_m
if err != nil {
return err
}
// Prevent insert being called with an empty slice which would result in
// err "no element on slice when insert".
if len(templateLabels) == 0 {
return nil
}

newLabels := make([]*issues_model.Label, 0, len(templateLabels))
for _, templateLabel := range templateLabels {
Expand Down

0 comments on commit b43d7e1

Please sign in to comment.