diff options
author | yp05327 <576951401@qq.com> | 2024-01-15 16:43:53 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 07:43:53 +0000 |
commit | c7e4629c0245cf6731ea34c2aa6ba4b968ea184a (patch) | |
tree | f760e43b7955473a7aa1a921c16e4b74a5d61a98 /modules/private/key.go | |
parent | 5d3fdd121279c758f247a76e020799aa5e548feb (diff) | |
download | gitea-c7e4629c0245cf6731ea34c2aa6ba4b968ea184a.tar.gz gitea-c7e4629c0245cf6731ea34c2aa6ba4b968ea184a.zip |
Fix nil pointer panic when exec some gitea cli command (#28791)
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)
Diffstat (limited to 'modules/private/key.go')
-rw-r--r-- | modules/private/key.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/private/key.go b/modules/private/key.go index 6f7cd87796..aa1e8aa56f 100644 --- a/modules/private/key.go +++ b/modules/private/key.go @@ -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 } |