From b1698117c2ca3cd7dd2dde59191898f980c17876 Mon Sep 17 00:00:00 2001 From: Remi Gillig Date: Wed, 9 Apr 2014 22:11:34 +0100 Subject: [PATCH] Fix memory leak that's been there for 5 years but nobody noticed until now :) Fixes #3. --- XInputDotNetPure/GamePad.cs | 1 + 1 file changed, 1 insertion(+) 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); }