Skip to content

Commit

Permalink
Merge pull request #119 from adriansr/fix_leak
Browse files Browse the repository at this point in the history
Fix memory leak when calling CommandLineToArgv
  • Loading branch information
Adrian Serrano authored May 8, 2019
2 parents 90a2865 + a1669fd commit d14a2f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Fix memory leak when getting process arguments. #119

### Changed

### Deprecated
Expand Down
4 changes: 4 additions & 0 deletions sys/windows/syscall_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ func ByteSliceToStringSlice(utf16 []byte) ([]string, error) {
if err != nil {
return nil, err
}

// Free memory allocated for CommandLineToArgvW arguments.
defer syscall.LocalFree((syscall.Handle)(unsafe.Pointer(argsWide)))

args := make([]string, numArgs)
for idx := range args {
args[idx] = syscall.UTF16ToString(argsWide[idx][:])
Expand Down

0 comments on commit d14a2f2

Please sign in to comment.