1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 03:12:20 +01:00

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

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