From bba55185de5ec142cbe8f65ec95287d05c51ab76 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 26 Apr 2024 17:41:38 +0200 Subject: [PATCH] utf8: let utf8_console_width() handle NULL strings somewhat reasonably --- src/basic/utf8.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/basic/utf8.c b/src/basic/utf8.c index b5711f4300..15deef1ffd 100644 --- a/src/basic/utf8.c +++ b/src/basic/utf8.c @@ -597,11 +597,14 @@ size_t utf8_n_codepoints(const char *str) { } size_t utf8_console_width(const char *str) { - size_t n = 0; + + if (isempty(str)) + return 0; /* Returns the approximate width a string will take on screen when printed on a character cell * terminal/console. */ + size_t n = 0; while (*str) { int w;