Fix index underflow causing segfault on DPI change (#241)
* Fix index underflow causing segfault on DPI change * Stop over-allocating sensor lists
This commit is contained in:
parent
990f923e7a
commit
7b297fc49f
|
@ -103,9 +103,10 @@ void DPI::setDPI(uint16_t dpi, uint8_t sensor)
|
||||||
hidpp20::AdjustableDPI::SensorDPIList dpi_list;
|
hidpp20::AdjustableDPI::SensorDPIList dpi_list;
|
||||||
if(_dpi_lists.size() <= sensor) {
|
if(_dpi_lists.size() <= sensor) {
|
||||||
dpi_list = _adjustable_dpi->getSensorDPIList(sensor);
|
dpi_list = _adjustable_dpi->getSensorDPIList(sensor);
|
||||||
for(std::size_t i = _dpi_lists.size()-1; i <= sensor; i++) {
|
for(std::size_t i = _dpi_lists.size(); i < sensor; i++) {
|
||||||
_dpi_lists.push_back(_adjustable_dpi->getSensorDPIList(i));
|
_dpi_lists.push_back(_adjustable_dpi->getSensorDPIList(i));
|
||||||
}
|
}
|
||||||
|
_dpi_lists.push_back(dpi_list);
|
||||||
}
|
}
|
||||||
dpi_list = _dpi_lists[sensor];
|
dpi_list = _dpi_lists[sensor];
|
||||||
_adjustable_dpi->setSensorDPI(sensor, getClosestDPI(dpi_list, dpi));
|
_adjustable_dpi->setSensorDPI(sensor, getClosestDPI(dpi_list, dpi));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user