diff --git a/XInputDotNetPure/GamePad.cs b/XInputDotNetPure/GamePad.cs index 49e476b..93beed0 100644 --- a/XInputDotNetPure/GamePad.cs +++ b/XInputDotNetPure/GamePad.cs @@ -336,6 +336,7 @@ public static GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone dea IntPtr gamePadStatePointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(GamePadState.RawState))); uint result = Imports.XInputGamePadGetState((uint)playerIndex, gamePadStatePointer); GamePadState.RawState state = (GamePadState.RawState)Marshal.PtrToStructure(gamePadStatePointer, typeof(GamePadState.RawState)); + Marshal.FreeHGlobal(gamePadStatePointer); return new GamePadState(result == Utils.Success, state, deadZone); }