From ff4905b2a22bbda5550cfea7cb16e258642ab30e Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Tue, 13 Jul 2021 14:07:45 +0300 Subject: [PATCH] Pull request: aghnet: fix impap iteration Updates #3346. Squashed commit of the following: commit d244cd1cc43a8c8e25b51d1117fa6fca1f4dcb18 Author: Ainar Garipov Date: Mon Jul 12 21:52:39 2021 +0300 aghnet: fix impap iteration --- internal/aghnet/ipmap.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/aghnet/ipmap.go b/internal/aghnet/ipmap.go index 78b3025d..281e27ee 100644 --- a/internal/aghnet/ipmap.go +++ b/internal/aghnet/ipmap.go @@ -74,6 +74,11 @@ func (m *IPMap) Range(f func(ip net.IP, v interface{}) (cont bool)) { } for k, v := range m.m { + // Array slicing produces a pointer, so copy the array here. + // + // See https://github.com/AdguardTeam/AdGuardHome/issues/3346 + // as well as https://github.com/kyoh86/looppointer/issues/9. + k := k if !f(net.IP(k[:]), v) { break }