Explorar o código

Merge pull request #45070 from corhere/libnet/fix-networkdb-test-panic

libnet/networkdb: fix nil-dereference panic in test
Bjorn Neergaard %!s(int64=2) %!d(string=hai) anos
pai
achega
2f0e308c7d
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      libnetwork/networkdb/networkdb_test.go

+ 4 - 1
libnetwork/networkdb/networkdb_test.go

@@ -108,7 +108,10 @@ func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string
 		nn, nnok := db.networks[node]
 		nn, nnok := db.networks[node]
 		if nnok {
 		if nnok {
 			n, ok := nn[id]
 			n, ok := nn[id]
-			leaving := n.leaving
+			var leaving bool
+			if ok {
+				leaving = n.leaving
+			}
 			db.RUnlock()
 			db.RUnlock()
 			if present && ok {
 			if present && ok {
 				return
 				return