config: don’t crash (div-by-zero) if the alpha component is 0

This commit is contained in:
Daniel Eklöf 2020-11-05 21:14:42 +01:00
parent 220e43526c
commit f49652130d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 4 additions and 0 deletions

View file

@ -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

View file

@ -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;