From f295ecf52381ae9f72719c9faacdae2c3c8e37de Mon Sep 17 00:00:00 2001 From: pcca-matrix Date: Thu, 20 Feb 2025 16:41:05 +0100 Subject: [PATCH] N-Rage: Fix memory leak in GetN64ButtonArrayFromXAnalog and GetN64ButtonNameFromButtonCode Replaced dynamic allocations (new[]) with static buffers to prevent memory leaks. --- Source/nragev20/XInputController.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/nragev20/XInputController.cpp b/Source/nragev20/XInputController.cpp index 52b1bf3f1..4b66a5ab5 100644 --- a/Source/nragev20/XInputController.cpp +++ b/Source/nragev20/XInputController.cpp @@ -388,8 +388,7 @@ TCHAR * GetN64ButtonNameFromButtonCode( int Button ) { using namespace N64_BUTTONS; - TCHAR *btnName; - btnName = new TCHAR[10]; + static TCHAR btnName[10]; switch( Button ) { @@ -444,10 +443,9 @@ TCHAR * GetN64ButtonArrayFromXAnalog( LPXCONTROLLER gController, int XThStickOrX using namespace N64_BUTTONS; if( !gController || !gController->bConfigured ) - return NULL; + return _T(""); - TCHAR *name; - name = new TCHAR[15]; + static TCHAR name[15]; switch( XThStickOrXDpad ) {