From b812ff62f84c65e71463bfb8601780921574917a Mon Sep 17 00:00:00 2001 From: unclesam <2036253946@qq.com> Date: Sat, 22 Aug 2026 17:09:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(updater):=20=E8=B0=83=E6=95=B4=20HTTP=20?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E7=8A=B6=E6=80=81=E7=A0=81=E7=9A=84=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E9=80=BB=E8=BE=91=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复在 resp 为 nil 时可能引发状态码检查异常的问题 - 将状态码校验移至 defer resp.Body.Close() 之后以确保资源正确释放 --- internal/updater/checker.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/updater/checker.go b/internal/updater/checker.go index 25118d0..cd540dd 100644 --- a/internal/updater/checker.go +++ b/internal/updater/checker.go @@ -102,11 +102,15 @@ func CheckUpdate(force bool) *UpdateInfo { client := &http.Client{Timeout: httpTimeout} resp, err := client.Do(req) - if err != nil || resp == nil || resp.StatusCode != http.StatusOK { + if err != nil || resp == nil { return nil } defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return nil + } + var release struct { TagName string `json:"tag_name"` HTMLURL string `json:"html_url"`