Memory leak fixes from someone in GitHub issues 5739, 5744, 5745, 5746.

This commit is contained in:
nicm
2026-10-15 08:21:11 +00:00
committed by tmux update bot
parent 73d8f81c2c
commit 173e6a9e05
4 changed files with 13 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: hooks.c,v 1.16 2026/07/27 19:15:58 nicm Exp $ */ /* $OpenBSD: hooks.c,v 1.17 2026/10/15 08:21:11 nicm Exp $ */
/* /*
* Copyright (c) 2026 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2026 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -164,6 +164,7 @@ hooks_insert(struct cmdq_item *item, struct hooks_data *hd)
break; break;
case CMD_PARSE_SUCCESS: case CMD_PARSE_SUCCESS:
hooks_insert_one(item, hd, pr->cmdlist, state); hooks_insert_one(item, hd, pr->cmdlist, state);
cmd_list_free(pr->cmdlist);
break; break;
} }
} else { } else {
@@ -178,10 +179,12 @@ hooks_insert(struct cmdq_item *item, struct hooks_data *hd)
cmdq_error(item, "%s", cmdq_error(item, "%s",
pr->error); pr->error);
} }
free(pr->error);
break; break;
case CMD_PARSE_SUCCESS: case CMD_PARSE_SUCCESS:
item = hooks_insert_one(item, hd, item = hooks_insert_one(item, hd,
pr->cmdlist, state); pr->cmdlist, state);
cmd_list_free(pr->cmdlist);
break; break;
} }
} else { } else {

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: server-client.c,v 1.521 2026/10/15 07:48:05 nicm Exp $ */ /* $OpenBSD: server-client.c,v 1.522 2026/10/15 08:21:11 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2757,6 +2757,8 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg)
} else { } else {
values = args_from_vector(argc, argv); values = args_from_vector(argc, argv);
pr = cmd_parse_from_arguments(values, argc, NULL); pr = cmd_parse_from_arguments(values, argc, NULL);
args_free_values(values, argc);
free(values);
switch (pr->status) { switch (pr->status) {
case CMD_PARSE_ERROR: case CMD_PARSE_ERROR:
cause = pr->error; cause = pr->error;
@@ -2764,8 +2766,6 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg)
case CMD_PARSE_SUCCESS: case CMD_PARSE_SUCCESS:
break; break;
} }
args_free_values(values, argc);
free(values);
cmd_free_argv(argc, argv); cmd_free_argv(argc, argv);
if ((c->flags & CLIENT_READONLY) && if ((c->flags & CLIENT_READONLY) &&
!cmd_list_all_have(pr->cmdlist, CMD_READONLY)) { !cmd_list_all_have(pr->cmdlist, CMD_READONLY)) {

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: tty-term.c,v 1.113 2026/10/14 12:33:46 nicm Exp $ */ /* $OpenBSD: tty-term.c,v 1.114 2026/10/15 08:21:11 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -412,6 +412,8 @@ tty_term_apply(struct tty_term *term, const char *capabilities, int quiet,
continue; continue;
if (remove) { if (remove) {
if (code->type == TTYCODE_STRING)
free(code->value.string);
code->type = TTYCODE_NONE; code->type = TTYCODE_NONE;
continue; continue;
} }

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: window-customize.c,v 1.37 2026/10/08 07:50:05 nicm Exp $ */ /* $OpenBSD: window-customize.c,v 1.38 2026/10/15 08:21:11 nicm Exp $ */
/* /*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com> * Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1430,6 +1430,7 @@ monitor:
if (wo != NULL && options_owner(o) != wo) { if (wo != NULL && options_owner(o) != wo) {
parent = options_get_only(wo, name); parent = options_get_only(wo, name);
if (parent != NULL) { if (parent != NULL) {
free(value);
value = options_to_string(parent, NULL, 0); value = options_to_string(parent, NULL, 0);
xsnprintf(label, sizeof label, xsnprintf(label, sizeof label,
"Window value (from window %u): ", fs.wl->idx); "Window value (from window %u): ", fs.wl->idx);
@@ -1442,6 +1443,7 @@ monitor:
if (go != NULL && options_owner(o) != go) { if (go != NULL && options_owner(o) != go) {
parent = options_get_only(go, name); parent = options_get_only(go, name);
if (parent != NULL) { if (parent != NULL) {
free(value);
value = options_to_string(parent, NULL, 0); value = options_to_string(parent, NULL, 0);
if (!window_customize_write_value(ctx, s->cx, sx, if (!window_customize_write_value(ctx, s->cx, sx,
sy - (s->cy - cy), 0, "Global value: ", "%s%s%s", sy - (s->cy - cy), 0, "Global value: ", "%s%s%s",