Fix closeable panic

Fix closeable panic when conn == nil
This commit is contained in:
adwpc
2020-04-25 15:09:59 +08:00
parent 1fdc827100
commit dea84cf1fb
2 changed files with 6 additions and 0 deletions
+1
View File
@@ -48,6 +48,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
* [Jason Maldonis](https://github.com/jjmaldonis)
* [Nevio Vesic](https://github.com/0x19)
* [David Hamilton](https://github.com/dihamilton)
* [adwpc](https://github.com/adwpc)
### License
MIT License - see [LICENSE](LICENSE) for full text
+5
View File
@@ -22,6 +22,11 @@ type closeable interface {
// Close a net.Conn and log if we have a failure
func closeConnAndLog(c closeable, log logging.LeveledLogger, msg string) {
if c == nil {
log.Warnf("Conn is not allocated")
return
}
log.Warnf(msg)
if err := c.Close(); err != nil {
log.Warnf("Failed to close conn: %v", err)