aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-08-12 16:36:45 +0800
committerGitHub <noreply@github.com>2022-08-12 11:36:45 +0300
commitac9792c0c771fcc5f629af3a25ff9287f8327d87 (patch)
treed531556f863ea31f2a72af5921cccd9a09503f7a
parentf7c874cb1a51905f8b935e95bc5b98880ca6db8d (diff)
downloadgitea-ac9792c0c771fcc5f629af3a25ff9287f8327d87.tar.gz
gitea-ac9792c0c771fcc5f629af3a25ff9287f8327d87.zip
Check webhooks slice length before calling xorm (#20642) (#20768)
Fixes: #20641 Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: John Olheiser <john.olheiser@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Gabriel Vasile <gabriel.vasile@email.com>
-rw-r--r--models/webhook/webhook.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/models/webhook/webhook.go b/models/webhook/webhook.go
index 1b79a414ad..478a6a29ff 100644
--- a/models/webhook/webhook.go
+++ b/models/webhook/webhook.go
@@ -399,6 +399,10 @@ func CreateWebhook(ctx context.Context, w *Webhook) error {
// CreateWebhooks creates multiple web hooks
func CreateWebhooks(ctx context.Context, ws []*Webhook) error {
+ // xorm returns err "no element on slice when insert" for empty slices.
+ if len(ws) == 0 {
+ return nil
+ }
for i := 0; i < len(ws); i++ {
ws[i].Type = strings.TrimSpace(ws[i].Type)
}