Skip to content

Commit

Permalink
Fix incorrect slice addressing
Browse files Browse the repository at this point in the history
Slice was being filtered but the loop counter wasn't being modified

```
panic: runtime error: index out of range [1] with length 1

goroutine 8 [running]:
        /Users/sean/go/src/github.com/pion/mdns/conn.go:965 +0xb9c
        /Users/sean/go/src/github.com/pion/mdns/conn.go:976 +0x1e4
        /Users/sean/go/src/github.com/pion/mdns/conn.go:1018 +0x90
        /Users/sean/go/src/github.com/pion/mdns/conn.go:1013 +0x234
```
  • Loading branch information
Sean-Der committed Mar 19, 2024
1 parent 5402a07 commit b515cab
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,11 @@ func (c *Conn) readLoop(name string, pktConn ipPacketConn, inboundBufferSize int
c.mu.Lock()
for queryIdx := len(c.queries) - 1; queryIdx >= 0; queryIdx-- {
for answerIdx := len(answered) - 1; answerIdx >= 0; answerIdx-- {
answer := answered[answerIdx]
if c.queries[queryIdx] == answer {
if c.queries[queryIdx] == answered[answerIdx] {
c.queries = append(c.queries[:queryIdx], c.queries[queryIdx+1:]...)
answered = append(answered[:answerIdx], answered[answerIdx+1:]...)
queryIdx--
break
}
}
}
Expand Down

0 comments on commit b515cab

Please sign in to comment.