aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorGabriel Vasile <gabriel.vasile@email.com>2022-08-04 06:20:22 +0300
committerGitHub <noreply@github.com>2022-08-04 11:20:22 +0800
commit6c218f7a5c80d7446c0434a8a9bb22ab305dcf4d (patch)
tree4f5f27e221861fb3036286421b42fafc7b80f28d /services
parentb6bb3891fd8824c7606a3c297a1420b4e2378e62 (diff)
downloadgitea-6c218f7a5c80d7446c0434a8a9bb22ab305dcf4d.tar.gz
gitea-6c218f7a5c80d7446c0434a8a9bb22ab305dcf4d.zip
Check issue labels slice length before calling xorm Insert; fixes #20654 (#20655)
Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'services')
-rw-r--r--services/repository/template.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/services/repository/template.go b/services/repository/template.go
index d7e8145811..3f2291ad63 100644
--- a/services/repository/template.go
+++ b/services/repository/template.go
@@ -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 {