mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
mangenerator: check strdup was successfull
Check for strdup != NULL and drop unneeded zeroing when buffer is overwritten.
This commit is contained in:
parent
2724a09e58
commit
e2c017fdac
@ -1460,11 +1460,10 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
|
|||||||
|
|
||||||
if (_is_desc_line(line_argv[0]) && !skip && cmd) {
|
if (_is_desc_line(line_argv[0]) && !skip && cmd) {
|
||||||
char *desc = dm_pool_strdup(cmdtool->libmem, line_orig);
|
char *desc = dm_pool_strdup(cmdtool->libmem, line_orig);
|
||||||
if (cmd->desc) {
|
if (cmd->desc && desc) {
|
||||||
int newlen = strlen(cmd->desc) + strlen(desc) + 2;
|
int newlen = strlen(cmd->desc) + strlen(desc) + 2;
|
||||||
char *newdesc = dm_pool_alloc(cmdtool->libmem, newlen);
|
char *newdesc = dm_pool_alloc(cmdtool->libmem, newlen);
|
||||||
if (newdesc) {
|
if (newdesc) {
|
||||||
memset(newdesc, 0, newlen);
|
|
||||||
snprintf(newdesc, newlen, "%s %s", cmd->desc, desc);
|
snprintf(newdesc, newlen, "%s %s", cmd->desc, desc);
|
||||||
cmd->desc = newdesc;
|
cmd->desc = newdesc;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user