diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-08-23 11:04:22 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-08-23 11:04:22 +0000 |
commit | 78c2c963c1b9ff88160dc0240092a849751520a7 (patch) | |
tree | f220340e0a20b9ffacb9e247cc63753530c0bc49 | |
parent | e00babe98f49d94492059d694a779b7b5df21f7a (diff) |
Fix a few memory leaks.
-rw-r--r-- | usr.bin/tmux/cmd-parse.y | 11 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-source-file.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/key-bindings.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/spawn.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 3 |
5 files changed, 20 insertions, 11 deletions
diff --git a/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y index d5c3883ac25..10519d2b5e9 100644 --- a/usr.bin/tmux/cmd-parse.y +++ b/usr.bin/tmux/cmd-parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-parse.y,v 1.42 2021/08/22 13:00:28 nicm Exp $ */ +/* $OpenBSD: cmd-parse.y,v 1.43 2021/08/23 11:04:21 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -426,7 +426,7 @@ command : assignment arg = xcalloc(1, sizeof *arg); arg->type = CMD_PARSE_STRING; - arg->string = xstrdup($2); + arg->string = $2; TAILQ_INSERT_HEAD(&$$->arguments, arg, entry); } | optional_assignment TOKEN arguments @@ -443,7 +443,7 @@ command : assignment arg = xcalloc(1, sizeof *arg); arg->type = CMD_PARSE_STRING; - arg->string = xstrdup($2); + arg->string = $2; TAILQ_INSERT_HEAD(&$$->arguments, arg, entry); } @@ -543,13 +543,13 @@ argument : TOKEN { $$ = xcalloc(1, sizeof *$$); $$->type = CMD_PARSE_STRING; - $$->string = xstrdup($1); + $$->string = $1; } | EQUALS { $$ = xcalloc(1, sizeof *$$); $$->type = CMD_PARSE_STRING; - $$->string = xstrdup($1); + $$->string = $1; } | '{' argument_statements { @@ -817,7 +817,6 @@ cmd_parse_build_command(struct cmd_parse_command *cmd, goto out; values[count].type = ARGS_COMMANDS; values[count].cmdlist = pr->cmdlist; - values[count].cmdlist->references++; break; } count++; diff --git a/usr.bin/tmux/cmd-source-file.c b/usr.bin/tmux/cmd-source-file.c index f150186554e..fde4225ae70 100644 --- a/usr.bin/tmux/cmd-source-file.c +++ b/usr.bin/tmux/cmd-source-file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-source-file.c,v 1.52 2021/08/22 13:48:29 nicm Exp $ */ +/* $OpenBSD: cmd-source-file.c,v 1.53 2021/08/23 11:04:21 nicm Exp $ */ /* * Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org> @@ -66,6 +66,7 @@ static void cmd_source_file_complete(struct client *c, struct cmd_source_file_data *cdata) { struct cmdq_item *new_item; + u_int i; if (cfg_finished) { if (cdata->retval == CMD_RETURN_ERROR && @@ -76,6 +77,8 @@ cmd_source_file_complete(struct client *c, struct cmd_source_file_data *cdata) cmdq_insert_after(cdata->after, new_item); } + for (i = 0; i < cdata->nfiles; i++) + free(cdata->files[i]); free(cdata->files); free(cdata); } @@ -177,6 +180,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) cmdq_error(item, "%s: %s", path, error); retval = CMD_RETURN_ERROR; } + globfree(&g); free(pattern); continue; } @@ -184,6 +188,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) for (j = 0; j < g.gl_pathc; j++) cmd_source_file_add(cdata, g.gl_pathv[j]); + globfree(&g); } free(expanded); diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c index c4fc484d7e1..b4d6e1e3217 100644 --- a/usr.bin/tmux/key-bindings.c +++ b/usr.bin/tmux/key-bindings.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-bindings.c,v 1.138 2021/08/21 17:41:19 nicm Exp $ */ +/* $OpenBSD: key-bindings.c,v 1.139 2021/08/23 11:04:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -187,6 +187,7 @@ key_bindings_add(const char *name, key_code key, const char *note, int repeat, { struct key_table *table; struct key_binding *bd; + char *s; table = key_bindings_get_table(name, 1); @@ -216,8 +217,10 @@ key_bindings_add(const char *name, key_code key, const char *note, int repeat, bd->flags |= KEY_BINDING_REPEAT; bd->cmdlist = cmdlist; + s = cmd_list_print(bd->cmdlist, 0); log_debug("%s: %#llx %s = %s", __func__, bd->key, - key_string_lookup_key(bd->key, 1), cmd_list_print(bd->cmdlist, 0)); + key_string_lookup_key(bd->key, 1), s); + free(s); } void diff --git a/usr.bin/tmux/spawn.c b/usr.bin/tmux/spawn.c index 9317edf2938..4cde3474a50 100644 --- a/usr.bin/tmux/spawn.c +++ b/usr.bin/tmux/spawn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spawn.c,v 1.28 2021/03/11 06:31:05 nicm Exp $ */ +/* $OpenBSD: spawn.c,v 1.29 2021/08/23 11:04:21 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -179,6 +179,7 @@ spawn_window(struct spawn_context *sc, char **cause) /* Set the name of the new window. */ if (~sc->flags & SPAWN_RESPAWN) { + free(w->name); if (sc->name != NULL) { w->name = format_single(item, sc->name, c, s, NULL, NULL); diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index a76e966b95e..59107786ff2 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.208 2021/07/06 08:26:00 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.209 2021/08/23 11:04:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -211,6 +211,7 @@ make_label(const char *label, char **cause) free(paths); xasprintf(&base, "%s/tmux-%ld", path, (long)uid); + free(path); if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) { xasprintf(cause, "couldn't create directory %s (%s)", base, strerror(errno)); |