Check msg is not nil before access Question field

This commit is contained in:
Cuong Manh Le
2023-04-29 13:21:57 +07:00
committed by Cuong Manh Le
parent b267572b38
commit 704bc27dba
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ func (r *dotResolver) Resolve(ctx context.Context, msg *dns.Msg) (*dns.Msg, erro
// regardless of the machine DNS status.
dialer := newDialer(net.JoinHostPort(bootstrapDNS, "53"))
dnsTyp := uint16(0)
if len(msg.Question) > 0 {
if msg != nil && len(msg.Question) > 0 {
dnsTyp = msg.Question[0].Qtype
}