Skip to content

Commit

Permalink
re-add wmi releases
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Pickett committed Sep 11, 2024
1 parent 695d0c2 commit cf7f9b7
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions ee/wmi/wmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"context"
"fmt"
"log/slog"
"runtime"

"github.com/go-ole/go-ole"
"github.com/go-ole/go-ole/oleutil"
Expand Down Expand Up @@ -155,12 +154,7 @@ func Query(ctx context.Context, slogger *slog.Logger, className string, properti
defer serviceRaw.Clear()

service := serviceRaw.ToIDispatch()
if runtime.GOARCH != "arm64" {
// calling service.Release() and the serviceRaw.Clear() (or the reverse) causes
// a panic on arm64 (Exception 0xc0000005: Access Violation). The hunch is that on arm64
// one clears the memory of the other.
defer service.Release()
}
defer service.Release()

slogger.Log(ctx, slog.LevelDebug,
"running WMI query",
Expand All @@ -175,12 +169,7 @@ func Query(ctx context.Context, slogger *slog.Logger, className string, properti
defer resultRaw.Clear()

result := resultRaw.ToIDispatch()
if runtime.GOARCH != "arm64" {
// calling result.Release() and then resultRaw.Clear() (or the reverse) causes
// a panic on arm64 (Exception 0xc0000005: Access Violation). The hunch is that on arm64
// one clears the memory of the other.
defer result.Release()
}
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 cf7f9b7

Please sign in to comment.