From 6a4b62579df795903052f8ce3a5fa680afd02d9f Mon Sep 17 00:00:00 2001 From: Paul Klinger Date: Wed, 13 Feb 2019 01:21:19 +0100 Subject: [PATCH] truncate display_block area if too large --- lcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lcd.c b/lcd.c index 2c5460a..6c91851 100644 --- a/lcd.c +++ b/lcd.c @@ -465,9 +465,9 @@ uint8_t lcd_check_buffer(uint8_t x, uint8_t y) { return displayBuffer[(y / (DISPLAY_HEIGHT/8))][x] & (1 << (y % (DISPLAY_HEIGHT/8))); } void lcd_display_block(uint8_t x, uint8_t line, uint8_t width) { - if (line > (DISPLAY_HEIGHT/8-1)) return; - if (x + width > DISPLAY_WIDTH - 1) { - width = DISPLAY_WIDTH - x - 1; + if (line > (DISPLAY_HEIGHT/8-1) || x > DISPLAY_WIDTH - 1){return;} + if (x + width > DISPLAY_WIDTH) { // no -1 here, x alone is width 1 + width = DISPLAY_WIDTH - x; } lcd_goto_xpix_y(x,line); lcd_data(&displayBuffer[line][x], width);