summaryrefslogtreecommitdiffhomepage
path: root/tracker-wii/wii_camera.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-03-14 13:47:30 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-03-14 14:21:02 +0100
commita53af220a7dd90791b998aa6a7b769b86da8a0c9 (patch)
tree54cf39b7a52d98272dcb018b423b93dd68bee807 /tracker-wii/wii_camera.cpp
parentac879b98b7556f0329a6aad48e3d1e2a80144ef2 (diff)
tracker/wii: fix memory errors
Issue: #876
Diffstat (limited to 'tracker-wii/wii_camera.cpp')
-rw-r--r--tracker-wii/wii_camera.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/tracker-wii/wii_camera.cpp b/tracker-wii/wii_camera.cpp
index af9a2d1f..90ad6385 100644
--- a/tracker-wii/wii_camera.cpp
+++ b/tracker-wii/wii_camera.cpp
@@ -119,7 +119,8 @@ wii_camera_status WIICamera::_pair()
wii_camera_status ret = wii_cam_wait_for_sync;
HBLUETOOTH_RADIO_FIND hbt;
BLUETOOTH_FIND_RADIO_PARAMS bt_param;
- HANDLE hbtlist[10];
+ constexpr int max_devices = 64;
+ HANDLE hbtlist[max_devices];
int ibtidx = 0;
bool wiifound = false;
@@ -127,9 +128,8 @@ wii_camera_status WIICamera::_pair()
hbt = BluetoothFindFirstRadio(&bt_param, hbtlist + ibtidx);
if (!hbt) { ret = wii_cam_wait_for_dongle; return ret; }
do
- {
ibtidx++;
- } while (BluetoothFindNextRadio(&bt_param, hbtlist + ibtidx));
+ while (ibtidx < max_devices && BluetoothFindNextRadio(&bt_param, hbtlist + ibtidx));
BluetoothFindRadioClose(hbt);
@@ -143,11 +143,12 @@ wii_camera_status WIICamera::_pair()
if (ERROR_SUCCESS != BluetoothGetRadioInfo(hbtlist[i], &btinfo)) {break;}
HBLUETOOTH_DEVICE_FIND hbtdevfd;
- BLUETOOTH_DEVICE_SEARCH_PARAMS btdevparam;
+ BLUETOOTH_DEVICE_SEARCH_PARAMS btdevparam {};
BLUETOOTH_DEVICE_INFO btdevinfo;
btdevinfo.dwSize = sizeof(btdevinfo);
btdevparam.dwSize = sizeof(btdevparam);
+ btdevparam.fReturnUnknown = TRUE;
btdevparam.fReturnAuthenticated = TRUE;
btdevparam.fReturnConnected = TRUE;
btdevparam.fReturnRemembered = TRUE;