Skip to content

Commit

Permalink
Fix assignment to entry in nil map
Browse files Browse the repository at this point in the history
We started using attributes to store headers instead of repeatedly
parsing them in every interceptor. This only works if the attributes are
initialized before they are used.
  • Loading branch information
mengelbart authored and Sean-Der committed Nov 23, 2021
1 parent d75d7da commit 937d3cd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/nack/generator_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func (n *GeneratorInterceptor) BindRemoteStream(info *interceptor.StreamInfo, re
return 0, nil, err
}

if attr == nil {
attr = make(interceptor.Attributes)
}
header, err := attr.GetRTPHeader(b[:i])
if err != nil {
return 0, nil, err
Expand Down
3 changes: 3 additions & 0 deletions pkg/nack/responder_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ func (n *ResponderInterceptor) BindRTCPReader(reader interceptor.RTCPReader) int
return 0, nil, err
}

if attr == nil {
attr = make(interceptor.Attributes)
}
pkts, err := attr.GetRTCPPackets(b[:i])
if err != nil {
return 0, nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/packetdump/receiver_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ func (r *ReceiverInterceptor) BindRemoteStream(info *interceptor.StreamInfo, rea
if err != nil {
return 0, nil, err
}

if attr == nil {
attr = make(interceptor.Attributes)
}

header, err := attr.GetRTPHeader(bytes)
if err != nil {
return 0, nil, err
Expand All @@ -66,10 +66,10 @@ func (r *ReceiverInterceptor) BindRTCPReader(reader interceptor.RTCPReader) inte
if err != nil {
return 0, nil, err
}

if attr == nil {
attr = make(interceptor.Attributes)
}

pkts, err := attr.GetRTCPPackets(bytes[:i])
if err != nil {
return 0, nil, err
Expand Down
6 changes: 6 additions & 0 deletions pkg/report/receiver_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func (r *ReceiverInterceptor) BindRemoteStream(info *interceptor.StreamInfo, rea
return 0, nil, err
}

if attr == nil {
attr = make(interceptor.Attributes)
}
header, err := attr.GetRTPHeader(b[:i])
if err != nil {
return 0, nil, err
Expand All @@ -154,6 +157,9 @@ func (r *ReceiverInterceptor) BindRTCPReader(reader interceptor.RTCPReader) inte
return 0, nil, err
}

if attr == nil {
attr = make(interceptor.Attributes)
}
pkts, err := attr.GetRTCPPackets(b[:i])
if err != nil {
return 0, nil, err
Expand Down
4 changes: 4 additions & 0 deletions pkg/twcc/sender_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ func (s *SenderInterceptor) BindRemoteStream(info *interceptor.StreamInfo, reade
if err != nil {
return 0, nil, err
}

if attr == nil {
attr = make(interceptor.Attributes)
}
header, err := attr.GetRTPHeader(buf[:i])
if err != nil {
return 0, nil, err
Expand Down

0 comments on commit 937d3cd

Please sign in to comment.