Skip to content

Commit

Permalink
Check issue labels slice length before calling xorm Insert; fixes #20654
Browse files Browse the repository at this point in the history
 (#20655)

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
4 people authored Aug 4, 2022
1 parent b6bb389 commit 6c218f7
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 @@ -23,6 +23,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 6c218f7

Please sign in to comment.