Fix panic caused by using range over slice len #1357

Merged
fyrchik merged 1 commit from elebedeva/frostfs-node:fix/out-of-range-panics into master 2024-09-06 10:36:52 +00:00
Showing only changes of commit f652518c24 - Show all commits

View file

@ -169,7 +169,7 @@ func (s *Server) getContainerNodes(contID cid.ID) ([]netmap.NodeInfo, error) {
nodes := placement.FlattenNodes(ns)
bs := (*keys.PublicKey)(&s.key.PublicKey).Bytes()
for i := range len(nodes) {
for i := 0; i < len(nodes); i++ { // don't use range, slice mutates in body
if bytes.Equal(nodes[i].PublicKey(), bs) {
copy(nodes[i:], nodes[i+1:])
nodes = nodes[:len(nodes)-1]