From a6eb22968c3e59fb86ac2dbb4c4edfcc57c8f7d1 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 19 Feb 2025 00:42:18 +0900 Subject: [PATCH] terminal-util: fix possible NULL pointer dereference Fixes a bug introduced by 94a2b1cd25c93870a7a4ac904f6c0f2e4f902038. Fixes CID#1591787. --- src/basic/terminal-util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 */ -- 2.47.3