From 4aa9c2607d38aa3ef426076b12583a0d2f241bb9 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:22:57 +0200 Subject: [PATCH] prevent overflow in color_blend --- wled00/colors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/colors.cpp b/wled00/colors.cpp index 23cf2f13..fd8febfd 100644 --- a/wled00/colors.cpp +++ b/wled00/colors.cpp @@ -11,7 +11,7 @@ IRAM_ATTR_YN __attribute__((hot)) uint32_t color_blend(uint32_t color1, uint32_t if(blend == 0) return color1; if (color1 == color2) return color1; // WLEDMM shortcut const uint_fast16_t blendmax = b16 ? 0xFFFF : 0xFF; - if(blend == blendmax) return color2; + if(blend >= blendmax) return color2; const uint_fast8_t shift = b16 ? 16 : 8; const uint_fast16_t blend2 = blendmax - blend; // WLEDMM pre-calculate value