jcs's openbsd hax
openbsd

Fixes for memory leaks reported by Lu Ming Yin, fixes from Howard Chu.

nicm 10e0aa77 79faa2ca

+13 -6
+5 -1
usr.bin/tmux/arguments.c
··· 1 - /* $OpenBSD: arguments.c,v 1.62 2023/11/14 20:01:11 nicm Exp $ */ 1 + /* $OpenBSD: arguments.c,v 1.63 2024/04/15 08:19:55 nicm Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com> ··· 171 171 if (optional_argument) { 172 172 log_debug("%s: -%c (optional)", __func__, flag); 173 173 args_set(args, flag, NULL, ARGS_ENTRY_OPTIONAL_VALUE); 174 + args_free_value(new); 175 + free(new); 174 176 return (0); /* either - or end */ 175 177 } 176 178 xasprintf(cause, "-%c expects an argument", flag); ··· 662 664 entry->count++; 663 665 if (value != NULL && value->type != ARGS_NONE) 664 666 TAILQ_INSERT_TAIL(&entry->values, value, entry); 667 + else 668 + free(value); 665 669 } 666 670 667 671 /* Get argument value. Will be NULL if it isn't present. */
+2 -1
usr.bin/tmux/cmd-command-prompt.c
··· 1 - /* $OpenBSD: cmd-command-prompt.c,v 1.66 2023/03/15 08:15:39 nicm Exp $ */ 1 + /* $OpenBSD: cmd-command-prompt.c,v 1.67 2024/04/15 08:19:55 nicm Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> ··· 143 143 cdata->prompt_type = status_prompt_type(type); 144 144 if (cdata->prompt_type == PROMPT_TYPE_INVALID) { 145 145 cmdq_error(item, "unknown type: %s", type); 146 + cmd_command_prompt_free(cdata); 146 147 return (CMD_RETURN_ERROR); 147 148 } 148 149 } else
+4 -2
usr.bin/tmux/cmd-confirm-before.c
··· 1 - /* $OpenBSD: cmd-confirm-before.c,v 1.53 2023/04/28 06:12:27 nicm Exp $ */ 1 + /* $OpenBSD: cmd-confirm-before.c,v 1.54 2024/04/15 08:19:55 nicm Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> ··· 76 76 77 77 cdata = xcalloc(1, sizeof *cdata); 78 78 cdata->cmdlist = args_make_commands_now(self, item, 0, 1); 79 - if (cdata->cmdlist == NULL) 79 + if (cdata->cmdlist == NULL) { 80 + free(cdata); 80 81 return (CMD_RETURN_ERROR); 82 + } 81 83 82 84 if (wait) 83 85 cdata->item = item;
+2 -2
usr.bin/tmux/layout-custom.c
··· 1 - /* $OpenBSD: layout-custom.c,v 1.22 2023/02/02 09:24:59 nicm Exp $ */ 1 + /* $OpenBSD: layout-custom.c,v 1.23 2024/04/15 08:19:55 nicm Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com> ··· 230 230 /* Check the new layout. */ 231 231 if (!layout_check(lc)) { 232 232 *cause = xstrdup("size mismatch after applying layout"); 233 - return (-1); 233 + goto fail; 234 234 } 235 235 236 236 /* Resize to the layout size. */