ice icon indicating copy to clipboard operation
ice copied to clipboard

Potential Bug in func GetSelectedCandidatePair

Open shaheerem opened this issue 1 year ago • 0 comments

Your environment

What did you do?

We have an application which uses pion ice for connectivity & candidate gathering with coturn.

What did you expect?

I expected that GetSelectedCandidatePair() func would return err if selectedPair is nil, but it doesn't, it returns nil pairs and nil error.

What happened?

In my code, I had written this line:

` // the ice connection has been established successfully we are ready to start the proxy pair, err := conn.agent.GetSelectedCandidatePair()

if err != nil {
	return errors.Wrapf(err, "failed to get selected candidate pairs for %s", conn.config.RemoteId)
}

localCandidate := pair.Local.Address()
remoteCandidate := pair.Remote.Address()
    ...

` Here I was only checking if err is nil, then it returned, but in this case, it returned error as nil, and pair as nil as well. Which failed the next line. Although, it can be seen as a flaw in my code, but I think it should return error in case pairs are nil.

shaheerem avatar Nov 27 '24 15:11 shaheerem