diff options
author | Keith Packard <keithp@keithp.com> | 2020-11-17 15:19:46 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2020-11-17 15:19:46 -0800 |
commit | 95025ea167d87998ef0bd3ed25dfaa2c179cf712 (patch) | |
tree | 2d52b4282f6cdff516fbee57e7a89951d7c78592 | |
parent | 706ed45e0b58219bc623b8c5f963777a120d2844 (diff) |
Correct icon buffer width computation for truecolor terminals
Fix the test when computing size necessary for true color output to
use 'is_truecolor_term' instead of 'is_utf8_locale'. A non-utf8 locale
with a true color terminal would have under-allocated the
buffer. Also, check for truecolor first to match the output code.
This doesn't fix the fact that this code over-allocates by a factor of
two in this case, but that at least won't cause memory corruption.
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | xprop.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -788,10 +788,10 @@ Format_Icons (const unsigned long *icon, int len) display_width = width * 2; /* Two characters per icon pixel. */ icon_pixel_bytes = 1; - if (is_utf8_locale()) - icon_pixel_bytes = 3; /* Up to 3 bytes per character in that mode. */ - if (is_utf8_locale()) + if (is_truecolor_term()) icon_pixel_bytes = 25; /* 16 control characters, and up to 9 chars of RGB. */ + else if (is_utf8_locale()) + icon_pixel_bytes = 3; /* Up to 3 bytes per character in that mode. */ /* Initial tab, pixels, and newline. */ icon_line_bytes = 8 + display_width * icon_pixel_bytes + 1; |