From 8bcc06eedab0f65b0f1c6233ead60c688193e6a2 Mon Sep 17 00:00:00 2001 From: Godetta Date: Tue, 3 Nov 2026 17:40:14 +0500 Subject: [PATCH 1/2] Fixed nil pointer crash when adding remote candidate --- examples/ping-pong/main.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/ping-pong/main.go b/examples/ping-pong/main.go index 0229f877..f5cc9756 100644 --- a/examples/ping-pong/main.go +++ b/examples/ping-pong/main.go @@ -47,9 +47,12 @@ func remoteCandidate(_ http.ResponseWriter, r *http.Request) { panic(err) } - if err := iceAgent.AddRemoteCandidate(c); err != nil { //nolint:contextcheck - panic(err) + if c != nil { + if err := iceAgent.AddRemoteCandidate(c); err != nil { //nolint:contextcheck + panic(err) + } } + } func main() { //nolint @@ -70,6 +73,11 @@ func main() { //nolint remoteHTTPPort = 9000 } + iceAgent, err = ice.NewAgent() + if err != nil { + panic(err) + } + http.HandleFunc("/remoteAuth", remoteAuth) http.HandleFunc("/remoteCandidate", remoteCandidate) go func() { @@ -88,11 +96,6 @@ func main() { //nolint panic(err) } - iceAgent, err = ice.NewAgent() - if err != nil { - panic(err) - } - // When we have gathered a new ICE Candidate send it to the remote peer if err = iceAgent.OnCandidate(func(c ice.Candidate) { if c == nil { From 588c6f7611d86d765770a6cb7d631171f8a38b66 Mon Sep 17 00:00:00 2001 From: Godetta Date: Tue, 3 Nov 2026 18:12:46 +0500 Subject: [PATCH 2/2] Fix gofumpt and whitespace lint errors --- examples/ping-pong/main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/ping-pong/main.go b/examples/ping-pong/main.go index f5cc9756..af02a793 100644 --- a/examples/ping-pong/main.go +++ b/examples/ping-pong/main.go @@ -52,7 +52,6 @@ func remoteCandidate(_ http.ResponseWriter, r *http.Request) { panic(err) } } - } func main() { //nolint