From 9d2c7f21fcfb14793218522f386fd9986c959580 Mon Sep 17 00:00:00 2001 From: Bodmer Date: Fri, 1 Dec 2017 15:37:08 +0000 Subject: [PATCH] Correct Sprite odd pixel count width crash The 32 bit alignment offset must be checked for every line to prevent crash with odd pixel count lines. --- TFT_eSPI.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index 32a24c9..8be3a37 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -562,13 +562,14 @@ uint16_t TFT_eSPI::readPixel(int32_t x0, int32_t y0) data += dx + dy * w; - // Check alignment of pointer to 32 bits - uint8_t offset = (uint32_t)data & 0x3; dw <<= 1; - if (offset > dw) offset = dw; while (dh--) { + // Check alignment of pointer to 32 bits + uint8_t offset = (uint32_t)data & 0x3; + if (offset > dw) offset = dw; + int32_t len = dw; uint8_t* ptr = (uint8_t*)data;