[NOD-1535] Don't reuse pointers on loop (#1069)

* [NOD-1535] Don't reuse pointers on loop

* [NOD-1535] Don't reuse pointers on loop
This commit is contained in:
Ori Newman 2020-11-15 05:27:01 -08:00 committed by Svarog
parent aeded07815
commit b50421beee

View File

@ -55,8 +55,9 @@ func (hs HashSet) Subtract(other HashSet) HashSet {
diff := New()
for hash := range hs {
if !other.Contains(&hash) {
diff.Add(&hash)
hashCopy := hash
if !other.Contains(&hashCopy) {
diff.Add(&hashCopy)
}
}
@ -79,7 +80,8 @@ func (hs HashSet) ToSlice() []*externalapi.DomainHash {
slice := make([]*externalapi.DomainHash, 0, len(hs))
for hash := range hs {
slice = append(slice, &hash)
hashCopy := hash
slice = append(slice, &hashCopy)
}
return slice