Skip to content

Commit

Permalink
internal/gamepad: bug fix: memory leak on Xbox
Browse files Browse the repository at this point in the history
Updates #2084
  • Loading branch information
hajimehoshi committed Jul 15, 2022
1 parent c14403f commit 520a30f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/gamepad/api_xbox_windows.go
Expand Up @@ -246,3 +246,7 @@ func (i *_IGameInputReading) GetGamepadState() (_GameInputGamepadState, bool) {
r, _, _ := syscall.Syscall(i.vtbl.GetGamepadState, 2, uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&state)), 0)
return state, int32(r) != 0
}

func (i *_IGameInputReading) Release() {
syscall.Syscall(i.vtbl.Release, 1, uintptr(unsafe.Pointer(i)), 0, 0)
}
1 change: 1 addition & 0 deletions internal/gamepad/gamepad_xbox_windows.go
Expand Up @@ -131,6 +131,7 @@ func (n *nativeGamepadXbox) update(gamepads *gamepads) error {
if err != nil {
return err
}
defer r.Release()

state, ok := r.GetGamepadState()
if !ok {
Expand Down

0 comments on commit 520a30f

Please sign in to comment.