summaryrefslogtreecommitdiff
path: root/common/command.c
diff options
context:
space:
mode:
authorAdam Lackorzynski <[email protected]>2026-05-15 22:47:30 +0200
committerTom Rini <[email protected]>2026-05-27 17:59:16 -0600
commit8429766a7f08ebbc0e4bdd8bcc8939a6b3ebf251 (patch)
treeefe1ec64f1e8e8f4f3ac1b1c8348a916a9d3d5dd /common/command.c
parent7af4196d9e9beaae6a69586cd87bd861b7fc2cda (diff)
common/command.c: Avoid NULL pointer use in cmd_auto_complete
Avoid using ps_prompt having a NULL pointer. For that, use the same approach as in uboot_cli_readline(). Suggested-by: Simon Glass <[email protected]> Signed-off-by: Adam Lackorzynski <[email protected]> Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'common/command.c')
-rw-r--r--common/command.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/common/command.c b/common/command.c
index 0f9dd06d72b..eb2c2123534 100644
--- a/common/command.c
+++ b/common/command.c
@@ -367,11 +367,15 @@ int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp)
int i, j, k, len, seplen, argc;
int cnt;
char last_char;
-#ifdef CONFIG_CMDLINE_PS_SUPPORT
- const char *ps_prompt = env_get("PS1");
-#else
- const char *ps_prompt = CONFIG_SYS_PROMPT;
-#endif
+ const char *ps_prompt;
+
+ if (IS_ENABLED(CONFIG_CMDLINE_PS_SUPPORT)) {
+ ps_prompt = env_get("PS1");
+
+ if (!ps_prompt)
+ ps_prompt = CONFIG_SYS_PROMPT;
+ } else
+ ps_prompt = CONFIG_SYS_PROMPT;
if (strcmp(prompt, ps_prompt) != 0)
return 0; /* not in normal console */