Skip to content

Commit ce3fe72

Browse files
peer: fix a potential segfault
1 parent 993d585 commit ce3fe72

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pkg/peer/peer.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,17 @@ func (p *Peer[ID]) SubscribeTo(track *webrtc.TrackLocalStaticRTP) error {
105105
// Unsubscribes from the given list of tracks.
106106
func (p *Peer[ID]) UnsubscribeFrom(tracks []*webrtc.TrackLocalStaticRTP) {
107107
// That's unfortunately an O(m*n) operation, but we don't expect the number of tracks to be big.
108-
for _, presentTrack := range p.peerConnection.GetSenders() {
109-
if presentTrack.Track() == nil {
110-
continue
108+
for _, sender := range p.peerConnection.GetSenders() {
109+
currentTrack := sender.Track()
110+
if currentTrack == nil {
111+
return
111112
}
112113

113114
for _, trackToUnsubscribe := range tracks {
114-
presentTrackID, presentStreamID := presentTrack.Track().ID(), presentTrack.Track().StreamID()
115+
presentTrackID, presentStreamID := currentTrack.ID(), currentTrack.StreamID()
115116
trackID, streamID := trackToUnsubscribe.ID(), trackToUnsubscribe.StreamID()
116117
if presentTrackID == trackID && presentStreamID == streamID {
117-
if err := p.peerConnection.RemoveTrack(presentTrack); err != nil {
118+
if err := p.peerConnection.RemoveTrack(sender); err != nil {
118119
p.logger.WithError(err).Error("failed to remove track")
119120
}
120121
}

pkg/router.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ func (r *Router) handleMatrixEvent(evt *event.Event) {
102102
"type": evt.Type.Type,
103103
"user_id": userID,
104104
"conf_id": conferenceID,
105-
"call_id": callID,
106105
"device_id": deviceID,
107106
})
108107

0 commit comments

Comments
 (0)