terminal-util: fix possible NULL pointer dereference

Fixes a bug introduced by 94a2b1cd25.
Fixes CID#1591787.
This commit is contained in:
Yu Watanabe
2025-02-19 00:42:18 +09:00
committed by Lennart Poettering
parent 134bb7bfdf
commit a6eb22968c

View File

@@ -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 */