Skip to content

Commit

Permalink
Fix RTCPeerConnection.Close segfault
Browse files Browse the repository at this point in the history
Multiple calls to RTCPeerConnection.Close would cause a segfault in
OpenSSL. Closing the NetworkManager was incorrectly placed after
the `isClosed` early return.

This moves the networkManager.Close() after that early return

Resolves #109
  • Loading branch information
Sean-Der committed Sep 30, 2018
1 parent f3fa47c commit 64ea3a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rtcpeerconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,13 +733,13 @@ func (pc *RTCPeerConnection) SendRTCP(pkt rtcp.Packet) error {

// Close ends the RTCPeerConnection
func (pc *RTCPeerConnection) Close() error {
pc.networkManager.Close()

// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #2)
if pc.isClosed {
return nil
}

pc.networkManager.Close()

// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #3)
pc.isClosed = true

Expand Down

0 comments on commit 64ea3a3

Please sign in to comment.