From 37577f3bd4b1f4bdc1f667cd122795b8b280e36c Mon Sep 17 00:00:00 2001 From: Abirdcfly Date: Tue, 19 Jul 2022 10:39:08 +0800 Subject: [PATCH] fix a possible panic because of taking the address of nil Signed-off-by: Abirdcfly Kubernetes-commit: f8a9c32a47f5d12d1baabe90a62e8637d47110d3 --- tools/clientcmd/auth_loaders.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/clientcmd/auth_loaders.go b/tools/clientcmd/auth_loaders.go index 0e41277628..5153a95a2a 100644 --- a/tools/clientcmd/auth_loaders.go +++ b/tools/clientcmd/auth_loaders.go @@ -51,10 +51,10 @@ func (a *PromptingAuthLoader) LoadAuth(path string) (*clientauth.Info, error) { // Prompt for user/pass and write a file if none exists. if _, err := os.Stat(path); os.IsNotExist(err) { authPtr, err := a.Prompt() - auth := *authPtr if err != nil { return nil, err } + auth := *authPtr data, err := json.Marshal(auth) if err != nil { return &auth, err