From 95025ea167d87998ef0bd3ed25dfaa2c179cf712 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 17 Nov 2020 15:19:46 -0800 Subject: 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 --- xprop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'xprop.c') diff --git a/xprop.c b/xprop.c index f220604..ec82257 100644 --- a/xprop.c +++ b/xprop.c @@ -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; -- cgit v1.2.3