Add bounds check for X (#1371)

Avoid crash if a draw goes to a negative X position.
This commit is contained in:
Samuel Sieb 2020-11-12 00:55:42 -08:00 committed by GitHub
parent c9055f2aef
commit b493d5bba5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -132,7 +132,7 @@ void HOT MAX7219Component::draw_absolute_pixel_internal(int x, int y, Color colo
this->max_displaybuffer_.resize(x + 1, this->bckgrnd_);
}
if (y >= this->get_height_internal() || y < 0) // If pixel is outside display then dont draw
if ((y >= this->get_height_internal()) || (y < 0) || (x < 0)) // If pixel is outside display then dont draw
return;
uint16_t pos = x; // X is starting at 0 top left