Fix memory leak

pull/3941/head
Howard Chu 2024-04-14 00:17:32 +08:00
parent 43530d4397
commit 38a4f03b50
4 changed files with 6 additions and 2 deletions

View File

@ -171,6 +171,7 @@ args_parse_flag_argument(struct args_value *values, u_int count, char **cause,
if (optional_argument) {
log_debug("%s: -%c (optional)", __func__, flag);
args_set(args, flag, NULL, ARGS_ENTRY_OPTIONAL_VALUE);
args_free_value(new);
return (0); /* either - or end */
}
xasprintf(cause, "-%c expects an argument", flag);

View File

@ -143,6 +143,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
cdata->prompt_type = status_prompt_type(type);
if (cdata->prompt_type == PROMPT_TYPE_INVALID) {
cmdq_error(item, "unknown type: %s", type);
cmd_command_prompt_free(cdata);
return (CMD_RETURN_ERROR);
}
} else

View File

@ -76,8 +76,10 @@ cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
cdata = xcalloc(1, sizeof *cdata);
cdata->cmdlist = args_make_commands_now(self, item, 0, 1);
if (cdata->cmdlist == NULL)
if (cdata->cmdlist == NULL) {
cmd_confirm_before_free(cdata);
return (CMD_RETURN_ERROR);
}
if (wait)
cdata->item = item;

View File

@ -230,7 +230,7 @@ layout_parse(struct window *w, const char *layout, char **cause)
/* Check the new layout. */
if (!layout_check(lc)) {
*cause = xstrdup("size mismatch after applying layout");
return (-1);
goto fail;
}
/* Resize to the layout size. */