mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
In LiquidCrystal::setCursor(), check against length of _row_offsets as well
Before, the row value was maximized against _numlines already, but the value from _numlines is not limited anywhere, so it could be longer than the length of _row_offsets. This check makes sure the array bounds is never exceeded.
This commit is contained in:
parent
3fdda81a1a
commit
1786716a75
@ -182,6 +182,10 @@ void LiquidCrystal::home()
|
||||
|
||||
void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
|
||||
{
|
||||
const size_t max_lines = sizeof(_row_offsets) / sizeof(*_row_offsets);
|
||||
if ( row >= max_lines ) {
|
||||
row = max_lines - 1; // we count rows starting w/0
|
||||
}
|
||||
if ( row >= _numlines ) {
|
||||
row = _numlines - 1; // we count rows starting w/0
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user