net: call getSystemDNSConfig inside lookupWithFake to avoid nil dereference panic when running tests alone

It happens with tests that only call lookupWithFake, and before them no-one calls resolverConf.tryUpdate. running alone one of these: TestIssue8434, TestIssueNoSuchHostExists cause a nil dereference panic.

Change-Id: I3fccd96dff5b3c77b5420a7f73742acbafa80142
GitHub-Last-Rev: 7456fd16a7
GitHub-Pull-Request: golang/go#56759
Reviewed-on: https://go-review.googlesource.com/c/go/+/450856
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
Mateusz Poliwczak 2022-11-17 08:54:48 +00:00 committed by Gopher Robot
parent ea2d4a7ef6
commit 478b1d260a
1 changed files with 1 additions and 1 deletions

View File

@ -1443,7 +1443,7 @@ func TestDNSGoroutineRace(t *testing.T) {
func lookupWithFake(fake fakeDNSServer, name string, typ dnsmessage.Type) error { func lookupWithFake(fake fakeDNSServer, name string, typ dnsmessage.Type) error {
r := Resolver{PreferGo: true, Dial: fake.DialContext} r := Resolver{PreferGo: true, Dial: fake.DialContext}
conf := resolvConf.dnsConfig.Load() conf := getSystemDNSConfig()
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()