mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
Check for nil when loading atomic values
This is required to prevent an error when values are loaded without first being set.
This commit is contained in:
@@ -47,6 +47,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
|
||||
* [Chao Yuan](https://github.com/yuanchao0310)
|
||||
* [Jason Maldonis](https://github.com/jjmaldonis)
|
||||
* [Nevio Vesic](https://github.com/0x19)
|
||||
* [David Hamilton](https://github.com/dihamilton)
|
||||
|
||||
### License
|
||||
MIT License - see [LICENSE](LICENSE) for full text
|
||||
|
||||
+10
-2
@@ -194,7 +194,11 @@ func (c *candidateBase) String() string {
|
||||
// LastReceived returns a time.Time indicating the last time
|
||||
// this candidate was received
|
||||
func (c *candidateBase) LastReceived() time.Time {
|
||||
return c.lastReceived.Load().(time.Time)
|
||||
lastReceived := c.lastReceived.Load()
|
||||
if lastReceived == nil {
|
||||
return time.Time{}
|
||||
}
|
||||
return lastReceived.(time.Time)
|
||||
}
|
||||
|
||||
func (c *candidateBase) setLastReceived(t time.Time) {
|
||||
@@ -204,7 +208,11 @@ func (c *candidateBase) setLastReceived(t time.Time) {
|
||||
// LastSent returns a time.Time indicating the last time
|
||||
// this candidate was sent
|
||||
func (c *candidateBase) LastSent() time.Time {
|
||||
return c.lastSent.Load().(time.Time)
|
||||
lastSent := c.lastSent.Load()
|
||||
if lastSent == nil {
|
||||
return time.Time{}
|
||||
}
|
||||
return lastSent.(time.Time)
|
||||
}
|
||||
|
||||
func (c *candidateBase) setLastSent(t time.Time) {
|
||||
|
||||
Reference in New Issue
Block a user