mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user