浏览代码

lib/nat: Don't crash on empty address list (fixes #9503) (#9504)

Jakob Borg 1 年之前
父节点
当前提交
79ae24df76
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. 2 3
      lib/nat/service.go

+ 2 - 3
lib/nat/service.go

@@ -233,9 +233,8 @@ func (s *Service) verifyExistingLocked(ctx context.Context, mapping *Mapping, na
 		default:
 		default:
 		}
 		}
 
 
-		// Delete addresses for NATDevice's that do not exist anymore
-		nat, ok := nats[id]
-		if !ok {
+		if nat, ok := nats[id]; !ok || len(extAddrs) == 0 {
+			// Delete addresses for NATDevice's that do not exist anymore
 			mapping.removeAddressLocked(id)
 			mapping.removeAddressLocked(id)
 			change = true
 			change = true
 			continue
 			continue