From f49652130dbe7d7f1cea770c501f32d3664a72c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 5 Nov 2020 21:14:42 +0100 Subject: [PATCH] =?UTF-8?q?config:=20don=E2=80=99t=20crash=20(div-by-zero)?= =?UTF-8?q?=20if=20the=20alpha=20component=20is=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + config.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95c1007..115c7a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ (https://codeberg.org/dnkl/yambar/issues/12). * mpd: fix compilation with clang (https://codeberg.org/dnkl/yambar/issues/16). +* Crash when the alpha component in a color value was 0. ### Security diff --git a/config.c b/config.c index 556891c..743a1a3 100644 --- a/config.c +++ b/config.c @@ -53,6 +53,9 @@ conf_to_color(const struct yml_node *node) uint16_t blue = hex_byte(&hex[4]); uint16_t alpha = hex_byte(&hex[6]); + if (alpha == 0) + return (pixman_color_t){0, 0, 0, 0}; + alpha |= alpha << 8; int alpha_div = 0xffff / alpha;