From f64a24e0ef96c1068a6031cb65b157d0d1c47097 Mon Sep 17 00:00:00 2001 From: Alexey Sharov Date: Thu, 2 Feb 2023 23:22:29 +0100 Subject: [PATCH] Fixed memory leak when using createPalette from FLASH --- Extensions/Sprite.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Extensions/Sprite.cpp b/Extensions/Sprite.cpp index 80dadfe..c7301a2 100644 --- a/Extensions/Sprite.cpp +++ b/Extensions/Sprite.cpp @@ -254,6 +254,11 @@ void TFT_eSprite::createPalette(uint16_t colorMap[], uint8_t colors) ***************************************************************************************/ void TFT_eSprite::createPalette(const uint16_t colorMap[], uint8_t colors) { + if (_colorMap != nullptr) + { + free(_colorMap); + } + if (colorMap == nullptr) { // Create a color map using the default FLASH map