fix(agent): add ok check for LoadAndDelete type assertion
sync.Map.LoadAndDelete returns any; unprotected type assertion could panic if an unexpected type were stored. Add ok check to safely handle mismatched types.
This commit is contained in:
parent
5224b9a4bc
commit
f0f809db35
1 changed files with 4 additions and 1 deletions
|
|
@ -88,7 +88,10 @@ func (al *AgentLoop) UnsubscribeEvents(id uint64) {
|
|||
if !ok {
|
||||
return
|
||||
}
|
||||
sub := value.(legacyEventSubscription)
|
||||
sub, ok := value.(legacyEventSubscription)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
sub.cancel()
|
||||
if sub.sub != nil {
|
||||
_ = sub.sub.Close()
|
||||
|
|
|
|||
Loading…
Reference in a new issue