Skip to content

Commit

Permalink
Merge pull request #693 from Jarrah-libremfg/main
Browse files Browse the repository at this point in the history
Fix unchecked type assertion in Subscription Stats
  • Loading branch information
magiconair authored Oct 24, 2023
2 parents 570ef42 + e32a4b1 commit 1782ad0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,16 @@ func (s *Subscription) Stats(ctx context.Context) (*ua.SubscriptionDiagnosticsDa
return nil, errors.Errorf("empty SubscriptionDiagnostics for sub=%d", s.SubscriptionID)
}

for _, eo := range v.Value().([]*ua.ExtensionObject) {
stat := eo.Value.(*ua.SubscriptionDiagnosticsDataType)
eos, ok := v.Value().([]*ua.ExtensionObject)
if !ok {
return nil, errors.Errorf("invalid type for SubscriptionDiagnosticsArray. Want []*ua.ExtensionObject. subID=%d nodeID=%s type=%T", s.SubscriptionID, node.String(), v.Value())
}

for _, eo := range eos {
stat, ok := eo.Value.(*ua.SubscriptionDiagnosticsDataType)
if !ok {
continue
}

if stat.SubscriptionID == s.SubscriptionID {
return stat, nil
Expand Down

0 comments on commit 1782ad0

Please sign in to comment.