X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fhelper%2Fcommand.c;h=ec66c2d2982e2050621a05496a04f93d7d831e3e;hp=869eff559cdd0836b760744bd1052439e093807a;hb=c19de41a0f49ee11eb474c51dc243383047bd663;hpb=b61e454869c988e7fafc1c16982ccfec04415b51 diff --git a/src/helper/command.c b/src/helper/command.c index 869eff559c..ec66c2d298 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -1119,7 +1119,7 @@ int help_add_command(struct command_context *cmd_ctx, struct command *parent, .name = cmd_name, .mode = COMMAND_ANY, .help = help_text, - .usage = usage, + .usage = usage ? : "", }; nc = register_command(cmd_ctx, parent, &cr); if (NULL == nc) { @@ -1144,8 +1144,9 @@ int help_add_command(struct command_context *cmd_ctx, struct command *parent, if (usage) { bool replaced = false; if (nc->usage) { + if (*nc->usage) + replaced = true; free(nc->usage); - replaced = true; } nc->usage = strdup(usage); if (replaced)