From 0810561a8a59deecaff0eba2805a23d3f49f32a6 Mon Sep 17 00:00:00 2001 From: Xhofe Date: Mon, 18 Apr 2022 18:29:21 +0800 Subject: [PATCH] fix(xunlei): check err prevent stack overflow --- drivers/xunlei/xunlei.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/xunlei/xunlei.go b/drivers/xunlei/xunlei.go index 89440da0..2e9d4c23 100644 --- a/drivers/xunlei/xunlei.go +++ b/drivers/xunlei/xunlei.go @@ -245,12 +245,18 @@ func (s *State) Request(method string, url string, callback func(*resty.Request) log.Debug(res.String()) var e Erron - utils.Json.Unmarshal(res.Body(), &e) + err = utils.Json.Unmarshal(res.Body(), &e) + if err != nil { + return nil, err + } switch e.ErrorCode { case 9: - s.newCaptchaToken(getAction(method, url), nil, account) + _, err = s.newCaptchaToken(getAction(method, url), nil, account) + if err != nil { + return nil, err + } fallthrough - case 4122, 4121: + case 4122, 4121: // Authorization expired return s.Request(method, url, callback, account) case 0: if res.StatusCode() == http.StatusOK {