Skip to content

Commit e1591c4

Browse files
authored
Fix: Intn Panic when the len is 0 (#617)
1 parent cc26eb1 commit e1591c4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

plugin/coser/coser.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ func init() {
4444
return "", err
4545
}
4646
arr := gjson.Get(helper.BytesToString(data), "data.data").Array()
47+
if len(arr) == 0 {
48+
return "", errors.New("data is empty")
49+
}
4750
pic := arr[rand.Intn(len(arr))]
4851
return pic.String(), nil
4952
}, web.GetData, time.Minute)

0 commit comments

Comments
 (0)