Skip to content

Commit

Permalink
Check issue labels slice length before calling xorm Insert; fixes go-…
Browse files Browse the repository at this point in the history
…gitea#20654 (go-gitea#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 and Sysoev, Vladimir committed Aug 10, 2022
1 parent a43c0b4 commit cf0fca3
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 cf0fca3

Please sign in to comment.