From 06af130bb7c042d8a44720cc9423b3fc76deadee Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Tue, 25 Aug 2020 13:38:52 +0300 Subject: [PATCH] - DHCP: fix crash after adding static lease which replaces the dynamic one --- dhcpd/v4.go | 3 +++ dhcpd/v6.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dhcpd/v4.go b/dhcpd/v4.go index b283079a..997b69f8 100644 --- a/dhcpd/v4.go +++ b/dhcpd/v4.go @@ -146,6 +146,9 @@ func (s *v4Server) rmDynamicLease(lease Lease) error { } s.leaseRemoveSwapByIndex(i) + if i == len(s.leases) { + break + } l = s.leases[i] } diff --git a/dhcpd/v6.go b/dhcpd/v6.go index 8f042e25..5259777a 100644 --- a/dhcpd/v6.go +++ b/dhcpd/v6.go @@ -134,6 +134,9 @@ func (s *v6Server) rmDynamicLease(lease Lease) error { } s.leaseRemoveSwapByIndex(i) + if i == len(s.leases) { + break + } l = s.leases[i] }