Skip to content

Commit cf0fca3

Browse files
gabriel-vasile6543lafrikstechknowlogick
authored and
Sysoev, Vladimir
committed
Check issue labels slice length before calling xorm Insert; fixes go-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>
1 parent a43c0b4 commit cf0fca3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

services/repository/template.go

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ func GenerateIssueLabels(ctx context.Context, templateRepo, generateRepo *repo_m
2323
if err != nil {
2424
return err
2525
}
26+
// Prevent insert being called with an empty slice which would result in
27+
// err "no element on slice when insert".
28+
if len(templateLabels) == 0 {
29+
return nil
30+
}
2631

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

0 commit comments

Comments
 (0)