common/cli.c: use memdup_nul() in run_command_list()

Use memdup_nul() instead of open-coding it.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
This commit is contained in:
Rasmus Villemoes
2026-04-21 09:54:37 +02:00
committed by Tom Rini
parent b87ff4878d
commit 11168813bf

View File

@@ -138,11 +138,9 @@ int run_command_list(const char *cmd, int len, int flag)
#endif
}
if (need_buff) {
buff = malloc(len + 1);
buff = memdup_nul(cmd, len);
if (!buff)
return 1;
memcpy(buff, cmd, len);
buff[len] = '\0';
}
#ifdef CONFIG_HUSH_PARSER
if (use_hush_old()) {