From 9f1cab154c8ac651a6468fd0f992602e6e1673cd Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 8 Nov 2021 17:45:31 -0500 Subject: [PATCH] lcd-16bit-common move bugfix to sim only Ive seen no ill effects having this disabled on target so limit it to the sim to stop Address Sanitizer from dumping on the extra byte read. the bad data is never used AFAICT since the loop ends Change-Id: I8cb54e9d1f8fe28747867d861a015edb3dbfa5ff --- firmware/drivers/lcd-16bit-common.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c index 25e3b89dc3..b9c9060216 100644 --- a/firmware/drivers/lcd-16bit-common.c +++ b/firmware/drivers/lcd-16bit-common.c @@ -316,6 +316,18 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, x += lcd_current_viewport->x; y += lcd_current_viewport->y; + /* 'Bugfix' mono_bitmap_part reads ahead in the buffer, While this is a bug + * if the height is <= char bit pixels other memory gets read but is not used + * the other option is to check in the hot code path but this appears + * sufficient, limit to the sim to stop Address Sanitizer errors + */ +#if defined(SIMULATOR) && \ + (!defined(LCD_STRIDEFORMAT) || LCD_STRIDEFORMAT != VERTICAL_STRIDE) + /* vertical stride targets don't seem affected by this */ + if (height <= CHAR_BIT) + stride = 0; +#endif + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ @@ -331,14 +343,6 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, x = 0; } - /* 'Bugfix' mono_bitmap_part reads ahead in the buffer, - * if the height is <= char bit pixels other memory gets read - * the other option is to check in the hot code path but this appears - * sufficient - */ - if (height <= CHAR_BIT) - stride = 0; - if (y < 0) { height += y;