Fix candidatePair.String() nil pointer

Resolves #197
This commit is contained in:
Will Forcey
2021-01-16 22:45:40 -08:00
committed by Sean DuBois
parent 9da25d95d8
commit c2e6f947d0
3 changed files with 13 additions and 0 deletions
+1
View File
@@ -61,6 +61,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
* [ZHENK](https://github.com/scorpionknifes)
* [Assad Obaid](https://github.com/assadobaid)
* [Antoine Baché](https://github.com/Antonito)
* [Will Forcey](https://github.com/wawesomeNOGUI)
### License
MIT License - see [LICENSE](LICENSE) for full text
+4
View File
@@ -26,6 +26,10 @@ type candidatePair struct {
}
func (p *candidatePair) String() string {
if p == nil {
return ""
}
return fmt.Sprintf("prio %d (local, prio %d) %s <-> %s (remote, prio %d)",
p.Priority(), p.local.Priority(), p.local, p.remote, p.remote.Priority())
}
+8
View File
@@ -122,3 +122,11 @@ func TestCandidatePairEquality(t *testing.T) {
t.Fatalf("Expected %v to equal %v", pairA, pairB)
}
}
func TestNilCandidatePairString(t *testing.T) {
var nilCandidatePair *candidatePair
if res := nilCandidatePair.String(); res != "" {
t.Fatalf("Expected %v to equal %v", res, "")
}
}