From 0e91f4ee1cba9f8885268f9184eb90df43773431 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 12 Dec 2021 17:09:29 +0100 Subject: [PATCH] device: Gracefully ignore invalid data index from raw input device --- panda/src/device/winRawInputDevice.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/panda/src/device/winRawInputDevice.cxx b/panda/src/device/winRawInputDevice.cxx index 96c9b1adbe..1370561852 100644 --- a/panda/src/device/winRawInputDevice.cxx +++ b/panda/src/device/winRawInputDevice.cxx @@ -663,7 +663,15 @@ process_report(PCHAR ptr, size_t size) { if (status == HIDP_STATUS_SUCCESS) { for (ULONG di = 0; di < count; ++di) { if (data[di].DataIndex != _hat_data_index) { - nassertd(data[di].DataIndex < _indices.size()) continue; + if (data[di].DataIndex >= _indices.size()) { + if (device_cat.is_debug()) { + device_cat.debug() + << "Ignoring out of range DataIndex " << data[di].DataIndex + << "from raw device " << _path << "\n"; + } + continue; + } + const Index &idx = _indices[data[di].DataIndex]; if (idx._axis >= 0) { if (idx._signed) {