Skip to content

Commit

Permalink
Merge pull request #18256 from hrydgard/control-mapper-fix-buffer-ove…
Browse files Browse the repository at this point in the history
…rflow

ControlMapper: Fix a range check and array size. In reality, probably not a danger.
  • Loading branch information
hrydgard committed Sep 27, 2023
2 parents 48d3efc + 65a7870 commit ed99e64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Core/ControlMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,9 @@ void ControlMapper::Axis(const AxisInput &axis) {
double now = time_now_d();

std::lock_guard<std::mutex> guard(mutex_);
if (axis.deviceId < DEVICE_ID_COUNT) {
deviceTimestamps_[(int)axis.deviceId] = now;
size_t deviceIndex = (size_t)axis.deviceId; // this'll wrap around ANY (-1) to max, which will eliminate it on the next line, if such an event appears by mistake.
if (deviceIndex < (size_t)DEVICE_ID_COUNT) {
deviceTimestamps_[deviceIndex] = now;
}
if (axis.value >= 0.0f) {
InputMapping mapping(axis.deviceId, axis.axisId, 1);
Expand Down
2 changes: 1 addition & 1 deletion Core/ControlMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ControlMapper {
float virtKeys_[VIRTKEY_COUNT]{};
bool virtKeyOn_[VIRTKEY_COUNT]{}; // Track boolean output separaately since thresholds may differ.

double deviceTimestamps_[42]{};
double deviceTimestamps_[(size_t)DEVICE_ID_COUNT]{};

int lastNonDeadzoneDeviceID_[2]{};

Expand Down

0 comments on commit ed99e64

Please sign in to comment.