Просмотр исходного кода

Fix: missing nil check caused crash when DisableApi set

Rod Hynes 9 лет назад
Родитель
Сommit
ac349dee4c
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      psiphon/tunnel.go

+ 2 - 1
psiphon/tunnel.go

@@ -898,7 +898,8 @@ func (tunnel *Tunnel) operateTunnel(tunnelOwner TunnelOwner) {
 	// timestamp in the handshake response as the tunnel start time. This time
 	// will be slightly earlier than the actual tunnel activation time, as the
 	// client has to receive and parse the response and activate the tunnel.
-	if !tunnel.IsDiscarded() {
+	// Tunnel does not have a serverContext when DisableApi is set.
+	if tunnel.serverContext != nil && !tunnel.IsDiscarded() {
 		err := RecordTunnelStats(
 			tunnel.serverContext.sessionId,
 			tunnel.serverContext.tunnelNumber,