Pull request: aghnet: fix impap iteration

Updates #3346.

Squashed commit of the following:

commit d244cd1cc43a8c8e25b51d1117fa6fca1f4dcb18
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Jul 12 21:52:39 2021 +0300

    aghnet: fix impap iteration
This commit is contained in:
Ainar Garipov 2021-07-13 14:07:45 +03:00
parent 194ea6ef95
commit ff4905b2a2
1 changed files with 5 additions and 0 deletions

View File

@ -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
}