Skip to content

Commit b169811

Browse files
committed
Fix memory leak that's been there for 5 years but nobody noticed until now :) Fixes #3.
1 parent 13b2e16 commit b169811

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

XInputDotNetPure/GamePad.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ public static GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone dea
336336
IntPtr gamePadStatePointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(GamePadState.RawState)));
337337
uint result = Imports.XInputGamePadGetState((uint)playerIndex, gamePadStatePointer);
338338
GamePadState.RawState state = (GamePadState.RawState)Marshal.PtrToStructure(gamePadStatePointer, typeof(GamePadState.RawState));
339+
Marshal.FreeHGlobal(gamePadStatePointer);
339340
return new GamePadState(result == Utils.Success, state, deadZone);
340341
}
341342

0 commit comments

Comments
 (0)