Skip to content

Commit 5d14ef8

Browse files
author
Rob Sanders
committed
Fix missing check after strdup, ensure error return if NULL, fix error message
1 parent 79bd141 commit 5d14ef8

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

libcli.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,6 +2465,10 @@ int cli_int_execute_buildmode(struct cli_def *cli) {
24652465
char *value = NULL;
24662466

24672467
cmdline = strdup(cli_command_name(cli, cli->buildmode->command));
2468+
if (!cmdline) {
2469+
cli_error(cli, "Unable to allocate memory to process buildmode commandline");
2470+
rc = CLI_ERROR;
2471+
}
24682472
for (optarg = cli->buildmode->command->optargs; rc == CLI_OK && optarg; optarg = optarg->next) {
24692473
value = NULL;
24702474
do {
@@ -2480,16 +2484,16 @@ int cli_int_execute_buildmode(struct cli_def *cli) {
24802484
} else if (value) {
24812485
if (optarg->flags & (CLI_CMD_OPTIONAL_FLAG | CLI_CMD_ARGUMENT)) {
24822486
if (!(cmdline = cli_int_buildmode_extend_cmdline(cmdline, value))) {
2483-
cli_error(cli, "Unable to append to building commandlne");
2487+
cli_error(cli, "Unable to allocate memory to process buildmode commandline");
24842488
rc = CLI_ERROR;
24852489
}
24862490
} else {
24872491
if (!(cmdline = cli_int_buildmode_extend_cmdline(cmdline, optarg->name))) {
2488-
cli_error(cli, "Unable to append to building commandlne");
2492+
cli_error(cli, "Unable to allocate memory to process buildmode commandline");
24892493
rc = CLI_ERROR;
24902494
}
24912495
if (!(cmdline = cli_int_buildmode_extend_cmdline(cmdline, value))) {
2492-
cli_error(cli, "Unable to append to building commandlne");
2496+
cli_error(cli, "Unable to allocate memory to process buildmode commandline");
24932497
rc = CLI_ERROR;
24942498
}
24952499
}

0 commit comments

Comments
 (0)