From: Yu Watanabe Date: Tue, 18 Feb 2025 15:42:18 +0000 (+0900) Subject: terminal-util: fix possible NULL pointer dereference X-Git-Tag: v258-rc1~1311 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6eb22968c3e59fb86ac2dbb4c4edfcc57c8f7d1;p=thirdparty%2Fsystemd.git terminal-util: fix possible NULL pointer dereference Fixes a bug introduced by 94a2b1cd25c93870a7a4ac904f6c0f2e4f902038. Fixes CID#1591787. --- diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 0a185776303..fce3bb95a3c 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -419,7 +419,10 @@ int ask_string_full( /* Ctrl-u → erase all input */ clear_by_backspace(utf8_console_width(string)); - string[n = 0] = 0; + if (string) + string[n = 0] = 0; + else + assert(n == 0); } else if (c == 4) { /* Ctrl-d → cancel this field input */