Fix: NRage plugin gets stuck in initialization in certain cases (#2464)
* Fix: NRage plugin gets stuck in initialization in certain cases The function wscanf was incorrectly used to parse VID_ and PID_ values from a string, causing failures in device detection. wscanf expects input from stdin, whereas in this case, the device ID string is stored in memory. Using swscanf ensures correct parsing from memory instead of waiting for stdin This fixes the issue where XInput devices not being detected properly at plugin init. * N-Rage: Fix memory leak in GetN64ButtonArrayFromXAnalog and GetN64ButtonNameFromButtonCode Replaced dynamic allocations (new[]) with static buffers to prevent memory leaks.
This commit is contained in:
parent
23ff3d9042
commit
9034bc6fdc
|
@ -105,10 +105,10 @@ BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput )
|
|||
// If it does, then get the VID/PID from var.bstrVal
|
||||
DWORD dwPid = 0, dwVid = 0;
|
||||
WCHAR* strVid = wcsstr( var.bstrVal, L"VID_" );
|
||||
if (strVid && wscanf(strVid, L"VID_%4X", &dwVid) != 1)
|
||||
if (strVid && swscanf(strVid, L"VID_%4X", &dwVid) != 1)
|
||||
dwVid = 0;
|
||||
WCHAR* strPid = wcsstr( var.bstrVal, L"PID_" );
|
||||
if (strPid && wscanf(strPid, L"PID_%4X", &dwPid) != 1)
|
||||
if (strPid && swscanf(strPid, L"PID_%4X", &dwPid) != 1)
|
||||
dwPid = 0;
|
||||
|
||||
// Compare the VID/PID to the DInput device
|
||||
|
@ -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 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue