Skip to content

Commit

Permalink
Fix candidatePair.String() nil pointer
Browse files Browse the repository at this point in the history
Resolves #197
  • Loading branch information
wawesomeNOGUI authored and Sean-Der committed Jan 17, 2021
1 parent 9da25d9 commit c2e6f94
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 4 additions & 0 deletions candidatepair.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
8 changes: 8 additions & 0 deletions candidatepair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
}
}

0 comments on commit c2e6f94

Please sign in to comment.