From: Lennart Poettering Date: Fri, 26 Apr 2024 15:41:38 +0000 (+0200) Subject: utf8: let utf8_console_width() handle NULL strings somewhat reasonably X-Git-Tag: v257-rc1~1144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bba55185de5ec142cbe8f65ec95287d05c51ab76;p=thirdparty%2Fsystemd.git utf8: let utf8_console_width() handle NULL strings somewhat reasonably --- diff --git a/src/basic/utf8.c b/src/basic/utf8.c index b5711f43001..15deef1ffd0 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;