From e1591c44b6de669c399795a61ddf7be6fa7dcac9 Mon Sep 17 00:00:00 2001 From: Fox_white <39846845+foxwhite25@users.noreply.github.com> Date: Sat, 11 Mar 2023 15:45:40 +0800 Subject: [PATCH] Fix: Intn Panic when the len is 0 (#617) --- plugin/coser/coser.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin/coser/coser.go b/plugin/coser/coser.go index e22a03d9..73b87ed2 100644 --- a/plugin/coser/coser.go +++ b/plugin/coser/coser.go @@ -44,6 +44,9 @@ func init() { return "", err } arr := gjson.Get(helper.BytesToString(data), "data.data").Array() + if len(arr) == 0 { + return "", errors.New("data is empty") + } pic := arr[rand.Intn(len(arr))] return pic.String(), nil }, web.GetData, time.Minute)