diff options
author | nicm <nicm> | 2021-08-23 11:04:21 +0000 |
---|---|---|
committer | nicm <nicm> | 2021-08-23 11:04:21 +0000 |
commit | 4a753dbefc2e67c218cf41141eaa6afab00f774a (patch) | |
tree | 6a52781c86c30894be0e2161c31154b3bdf953a0 | |
parent | 3ed37a207988bc6e96dc673ae4564a4efd682ea6 (diff) | |
download | rtmux-4a753dbefc2e67c218cf41141eaa6afab00f774a.tar.gz rtmux-4a753dbefc2e67c218cf41141eaa6afab00f774a.tar.bz2 rtmux-4a753dbefc2e67c218cf41141eaa6afab00f774a.zip |
Fix a few memory leaks.
-rw-r--r-- | cmd-parse.y | 9 | ||||
-rw-r--r-- | cmd-source-file.c | 5 | ||||
-rw-r--r-- | key-bindings.c | 5 | ||||
-rw-r--r-- | spawn.c | 1 | ||||
-rw-r--r-- | tmux.c | 1 |
5 files changed, 15 insertions, 6 deletions
diff --git a/cmd-parse.y b/cmd-parse.y index c27d530e..a08c5819 100644 --- a/cmd-parse.y +++ b/cmd-parse.y @@ -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/cmd-source-file.c b/cmd-source-file.c index fbe871ca..0bc02e05 100644 --- a/cmd-source-file.c +++ b/cmd-source-file.c @@ -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/key-bindings.c b/key-bindings.c index c0a959e2..e3b21d61 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -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 @@ -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); @@ -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)); |