Skip to content

Commit

Permalink
Fix registry handle leak on Windows (#33)
Browse files Browse the repository at this point in the history
Close the handles used to fetch the machine ID and OS version.

Fixes #30
  • Loading branch information
andrewkroh authored Dec 21, 2018
1 parent b550ae2 commit 7b7b5fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions providers/windows/machineid_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func getMachineGUID() (string, error) {
if err != nil {
return "", errors.Wrapf(err, `failed to open HKLM\%v`, path)
}
defer k.Close()

guid, _, err := k.GetStringValue(name)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions providers/windows/os_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func OperatingSystem() (*types.OSInfo, error) {
if err != nil {
return nil, errors.Wrapf(err, `failed to open HKLM\%v`, path)
}
defer k.Close()

osInfo := &types.OSInfo{
Family: "windows",
Expand Down

0 comments on commit 7b7b5fb

Please sign in to comment.