]> source.dussan.org Git - gitea.git/commitdiff
Fix nil pointer panic when exec some gitea cli command (#28791) (#28795)
authorGiteabot <teabot@gitea.io>
Mon, 15 Jan 2024 08:05:30 +0000 (16:05 +0800)
committerGitHub <noreply@github.com>
Mon, 15 Jan 2024 08:05:30 +0000 (08:05 +0000)
Backport #28791 by @yp05327

panic:

![image](https://github.com/go-gitea/gitea/assets/18380374/7fcde2ad-1d42-4b60-b120-3b60a8926e8e)

After:

![image](https://github.com/go-gitea/gitea/assets/18380374/49d9f0ca-e590-4a35-8ca2-1317d1b7c939)

Co-authored-by: yp05327 <576951401@qq.com>
modules/private/actions.go
modules/private/key.go
modules/private/mail.go

index c924dac2cd659c9c0646abc6382c69c3e34b267a..4ec77dc936086d5306b97bb9b8eb404a9161d398 100644 (file)
@@ -22,5 +22,8 @@ func GenerateActionsRunnerToken(ctx context.Context, scope string) (string, Resp
        })
 
        resp, extra := requestJSONResp(req, &responseText{})
+       if resp == nil {
+               return "", extra
+       }
        return resp.Text, extra
 }
index 6f7cd877962ce3dc7f85172694791d7de65830f0..aa1e8aa56f907dc3836dc56ab487d63d2f2d1d69 100644 (file)
@@ -27,5 +27,8 @@ func AuthorizedPublicKeyByContent(ctx context.Context, content string) (string,
        req := newInternalRequest(ctx, reqURL, "POST")
        req.Param("content", content)
        resp, extra := requestJSONResp(req, &responseText{})
+       if resp == nil {
+               return "", extra
+       }
        return resp.Text, extra
 }
index 82216b346b711fd39561fc535089e2168b20f482..699f5e5f42865facfd3b6d81636fd87c756dc2fc 100644 (file)
@@ -30,5 +30,8 @@ func SendEmail(ctx context.Context, subject, message string, to []string) (strin
        })
 
        resp, extra := requestJSONResp(req, &responseText{})
+       if resp == nil {
+               return "", extra
+       }
        return resp.Text, extra
 }