From 0e585044b61883d4cbeb43b79a8bb7ad19dab2d8 Mon Sep 17 00:00:00 2001 From: Pratik Mallya Date: Sun, 14 Jul 2019 19:34:07 -0700 Subject: [PATCH] oauth2: validate token in reuseTokenSource Without this check, for reuseTokenSource types that are created without a Token (which is permitted), the call to `Token` will fail since the value of the `reuseTokenSource.t` field (which holds the token) is nil. --- oauth2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oauth2.go b/oauth2.go index 291df5c83..951691bca 100644 --- a/oauth2.go +++ b/oauth2.go @@ -298,7 +298,7 @@ type reuseTokenSource struct { func (s *reuseTokenSource) Token() (*Token, error) { s.mu.Lock() defer s.mu.Unlock() - if s.t.Valid() { + if s.t != nil && s.t.Valid() { return s.t, nil } t, err := s.new.Token()