From e2c017fdace76f0c03f43e3e435ae8a72d6bb15f Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 21 Dec 2018 21:08:31 +0100 Subject: [PATCH] mangenerator: check strdup was successfull Check for strdup != NULL and drop unneeded zeroing when buffer is overwritten. --- tools/command.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/command.c b/tools/command.c index c994c3912..6931e44d4 100644 --- a/tools/command.c +++ b/tools/command.c @@ -1460,11 +1460,10 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name) if (_is_desc_line(line_argv[0]) && !skip && cmd) { char *desc = dm_pool_strdup(cmdtool->libmem, line_orig); - if (cmd->desc) { + if (cmd->desc && desc) { int newlen = strlen(cmd->desc) + strlen(desc) + 2; char *newdesc = dm_pool_alloc(cmdtool->libmem, newlen); if (newdesc) { - memset(newdesc, 0, newlen); snprintf(newdesc, newlen, "%s %s", cmd->desc, desc); cmd->desc = newdesc; } else { -- 2.43.5