Skip to content

Commit

Permalink
remove service and result release calls in wmi
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Pickett committed Sep 12, 2024
1 parent a0fa235 commit 331c29f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ee/wmi/wmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ func Query(ctx context.Context, slogger *slog.Logger, className string, properti
}
defer serviceRaw.Clear()

// the memory of result is released by `defer serviceRaw.Clear()` above,
// on windows arm64 machines, calling `service.Clear()` after `serviceRaw.Release()`
// would cause a panic
service := serviceRaw.ToIDispatch()
defer service.Release()

slogger.Log(ctx, slog.LevelDebug,
"running WMI query",
Expand All @@ -168,8 +170,10 @@ func Query(ctx context.Context, slogger *slog.Logger, className string, properti
}
defer resultRaw.Clear()

// the memory of result is released by `defer resultRaw.Clear()` above,
// on windows arm64 machines, calling `resultRaw.Clear()` after `result.Release()`
// would cause a panic
result := resultRaw.ToIDispatch()
defer result.Release()

if err := oleutil.ForEach(result, handler.HandleVariant); err != nil {
return nil, fmt.Errorf("ole foreach: %w", err)
Expand Down

0 comments on commit 331c29f

Please sign in to comment.