Commit 70e0205d authored by Matthijs Kooijman's avatar Matthijs Kooijman
Browse files

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.
parent 26ab1e1d
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment