Skip to content

Commit

Permalink
Fix packetmanager cause panic
Browse files Browse the repository at this point in the history
  • Loading branch information
tyohan committed Oct 21, 2024
1 parent 23203f8 commit 792a640
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/rtppool/packetmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewPacketManager() *PacketManager {

AttrPool: &sync.Pool{
New: func() interface{} {
return &interceptor.Attributes{}
return interceptor.Attributes{}
},
},
}
Expand Down Expand Up @@ -95,6 +95,11 @@ func (m *PacketManager) NewPacket(header *rtp.Header, payload []byte, attr inter
if !ok {
return nil, errFailedToCastPayloadPool
}

// copy map
for k, v := range attr {
p.attr[k] = v
}
}

return p, nil
Expand All @@ -108,6 +113,11 @@ func (m *PacketManager) releasePacket(header *rtp.Header, payload *[]byte, p *Re
}

if p.attr != nil {
// clear map
for k := range p.attr {
delete(p.attr, k)
}

m.AttrPool.Put(p.attr)
}

Expand Down

0 comments on commit 792a640

Please sign in to comment.