[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Restore check for nil writePipe in WebRTCPeer.Close.



commit 72cfb96edeb7c9a3c93d38539bc31a51e30dbe8d
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Tue Apr 28 11:33:09 2020 -0600

    Restore check for nil writePipe in WebRTCPeer.Close.
    
    I removed this check in 047d3214bfb46de07e5d9f223e4fb1ba24584c8a because
    NewWebRTCPeer always initializes writePipe, and it is never reset to
    nil. However tests used &WebRTCPeer{} which bypasses NewWebRTCPeer and
    leaves writePipe set to nil.
    
    https://bugs.torproject.org/34049#comment:3
    https://bugs.torproject.org/34050
---
 client/lib/webrtc.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go
index edc8ab4..23cb3e1 100644
--- a/client/lib/webrtc.go
+++ b/client/lib/webrtc.go
@@ -236,7 +236,9 @@ func exchangeSDP(broker *BrokerChannel, offer *webrtc.SessionDescription) *webrt
 // Close all channels and transports
 func (c *WebRTCPeer) cleanup() {
 	// Close this side of the SOCKS pipe.
-	c.writePipe.Close()
+	if c.writePipe != nil { // c.writePipe can be nil in tests.
+		c.writePipe.Close()
+	}
 	if nil != c.transport {
 		log.Printf("WebRTC: closing DataChannel")
 		c.transport.Close()

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits