diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-08-27 11:03:35 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2018-08-27 11:03:35 +0000 |
commit | 6558449e29af3d68372541baf42402e9a9df5d08 (patch) | |
tree | 01ca24ceced5913341404608b668f98a662a03ff /usr.bin/tmux | |
parent | 2abe2e180bad9b2f6e5b964b63bc85edfb8e3daf (diff) |
Memory leaks, from Gang Fan in GitHub issue 1453.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-if-shell.c | 11 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-load-buffer.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-run-shell.c | 10 | ||||
-rw-r--r-- | usr.bin/tmux/format.c | 6 |
4 files changed, 21 insertions, 9 deletions
diff --git a/usr.bin/tmux/cmd-if-shell.c b/usr.bin/tmux/cmd-if-shell.c index 8715bdac282..4af22e0dd29 100644 --- a/usr.bin/tmux/cmd-if-shell.c +++ b/usr.bin/tmux/cmd-if-shell.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-if-shell.c,v 1.59 2018/08/23 15:45:05 nicm Exp $ */ +/* $OpenBSD: cmd-if-shell.c,v 1.60 2018/08/27 11:03:34 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -120,8 +120,13 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) cdata->item = NULL; memcpy(&cdata->mouse, &shared->mouse, sizeof cdata->mouse); - job_run(shellcmd, s, server_client_get_cwd(item->client, s), NULL, - cmd_if_shell_callback, cmd_if_shell_free, cdata, 0); + if (job_run(shellcmd, s, server_client_get_cwd(item->client, s), NULL, + cmd_if_shell_callback, cmd_if_shell_free, cdata, 0) == NULL) { + cmdq_error(item, "failed to run command: %s", shellcmd); + free(shellcmd); + free(cdata); + return (CMD_RETURN_ERROR); + } free(shellcmd); if (args_has(args, 'b')) diff --git a/usr.bin/tmux/cmd-load-buffer.c b/usr.bin/tmux/cmd-load-buffer.c index 5309dc8925d..8e77995f5d6 100644 --- a/usr.bin/tmux/cmd-load-buffer.c +++ b/usr.bin/tmux/cmd-load-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-load-buffer.c,v 1.53 2018/07/31 13:06:44 nicm Exp $ */ +/* $OpenBSD: cmd-load-buffer.c,v 1.54 2018/08/27 11:03:34 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -87,6 +87,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item) if (error != 0) { cmdq_error(item, "-: %s", cause); free(cause); + free(cdata); return (CMD_RETURN_ERROR); } return (CMD_RETURN_WAIT); diff --git a/usr.bin/tmux/cmd-run-shell.c b/usr.bin/tmux/cmd-run-shell.c index a37ae46bace..cbb4a888cc9 100644 --- a/usr.bin/tmux/cmd-run-shell.c +++ b/usr.bin/tmux/cmd-run-shell.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-run-shell.c,v 1.54 2018/08/23 15:45:05 nicm Exp $ */ +/* $OpenBSD: cmd-run-shell.c,v 1.55 2018/08/27 11:03:34 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -102,8 +102,12 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item) if (!args_has(args, 'b')) cdata->item = item; - job_run(cdata->cmd, s, server_client_get_cwd(item->client, s), NULL, - cmd_run_shell_callback, cmd_run_shell_free, cdata, 0); + if (job_run(cdata->cmd, s, server_client_get_cwd(item->client, s), NULL, + cmd_run_shell_callback, cmd_run_shell_free, cdata, 0) == NULL) { + cmdq_error(item, "failed to run command: %s", cdata->cmd); + free(cdata); + return (CMD_RETURN_ERROR); + } if (args_has(args, 'b')) return (CMD_RETURN_NORMAL); diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 91540238436..e158941e09a 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.161 2018/08/26 09:28:42 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.162 2018/08/27 11:03:34 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1086,8 +1086,10 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, found = xstrdup(""); } } - if (format_choose(ptr + 1, &left, &right) != 0) + if (format_choose(ptr + 1, &left, &right) != 0) { + free(found); goto fail; + } if (format_true(found)) value = format_expand(ft, left); |