edgar-mtz-e / slimdx

Automatically exported from code.google.com/p/slimdx
0 stars 0 forks source link

Crash in RawInput.Device.GetDevices() #274

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In build from SVN revision 560 when calling RawInput.Device.GetDevices() I
always get corrupted heap (error dialog in debug build).

It's happening because following function call returns count of characters
of device name in size variable (line 199 in rawinput\Device.cpp file):
{{{
GetRawInputDeviceInfo( deviceList[i].hDevice, RIDI_DEVICENAME, NULL, &size );
}}}

Few lines below size variable is used as count of BYTE's resulting in heap
corruption (because SlimDX project is configured to use Unicode character set)
{{{
bytes = new BYTE[size];
GetRawInputDeviceInfo( deviceList[i].hDevice, RIDI_DEVICENAME, bytes, &size );
}}}

Following code fragment can be placed instead of existing in lines 203..206
to fix this problem:
{{{
TCHAR* bytes = new TCHAR [size];
GetRawInputDeviceInfo( deviceList[i].hDevice, RIDI_DEVICENAME, bytes, &size );

name = gcnew String(bytes);
}}}

Original issue reported on code.google.com by Martins....@gmail.com on 31 May 2008 at 8:15

GoogleCodeExporter commented 9 years ago
Very good. I haven't gotten around to writing a raw input sample yet, which 
would
have let me spot this.

Original comment by Mike.Popoloski on 31 May 2008 at 9:43

GoogleCodeExporter commented 9 years ago
Fixed.

Original comment by Mike.Popoloski on 1 Jun 2008 at 3:51