summaryrefslogtreecommitdiffhomepage
path: root/tracker-wii
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-02-22 15:09:28 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-02-22 15:09:28 +0100
commit388e9e57d8dcc1b5eda16670bae0e4518515504c (patch)
treeb98be48462fa392f4a4df4f1645007de54ad9494 /tracker-wii
parent4f66eb2bc9038dbac490ac540cdfe0188c91f672 (diff)
tracker/wii: fix heap corruption
Diffstat (limited to 'tracker-wii')
-rw-r--r--tracker-wii/wiiyourself/wiimote.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/tracker-wii/wiiyourself/wiimote.cpp b/tracker-wii/wiiyourself/wiimote.cpp
index 7a5ee833..f154a198 100644
--- a/tracker-wii/wiiyourself/wiimote.cpp
+++ b/tracker-wii/wiiyourself/wiimote.cpp
@@ -242,20 +242,22 @@ bool wiimote::Connect(unsigned wiimote_index, bool force_hidwrites)
{
// get the buffer size for this device detail instance
DWORD req_size = 0;
- SetupDiGetDeviceInterfaceDetail(dev_info, &didata, NULL, 0, &req_size, NULL);
+ if (!SetupDiGetDeviceInterfaceDetail(dev_info, &didata, NULL, 0, &req_size, NULL))
+ {
+ WARN(_T("couldn't get devinterface info for %u"), index);
+ break;
+ }
// (bizarre way of doing it) create a buffer large enough to hold the
// fixed-size detail struct components, and the variable string size
- using spdidd = SP_DEVICE_INTERFACE_DETAIL_DATA;
- constexpr std::align_val_t align { alignof(spdidd) };
- spdidd *didetail = (spdidd*)operator new(req_size, align);
- _ASSERT(didetail);
+ using spdidd = SP_DEVICE_INTERFACE_DETAIL_DATA;
+ spdidd *didetail = (spdidd*)operator new(req_size, (std::align_val_t)alignof(spdidd));
didetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
// now actually get the detail struct
if (!SetupDiGetDeviceInterfaceDetail(dev_info, &didata, didetail,
req_size, &req_size, NULL)) {
- WARN(_T("couldn't get devinterface info for %u"), index);
+ WARN(_T("couldn't get devinterface info for %u #2"), index);
break;
}