mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Fix a few memory leaks.
This commit is contained in:
		| @@ -426,7 +426,7 @@ command		: assignment | |||||||
|  |  | ||||||
| 			arg = xcalloc(1, sizeof *arg); | 			arg = xcalloc(1, sizeof *arg); | ||||||
| 			arg->type = CMD_PARSE_STRING; | 			arg->type = CMD_PARSE_STRING; | ||||||
| 			arg->string = xstrdup($2); | 			arg->string = $2; | ||||||
| 			TAILQ_INSERT_HEAD(&$$->arguments, arg, entry); | 			TAILQ_INSERT_HEAD(&$$->arguments, arg, entry); | ||||||
| 		} | 		} | ||||||
| 		| optional_assignment TOKEN arguments | 		| optional_assignment TOKEN arguments | ||||||
| @@ -443,7 +443,7 @@ command		: assignment | |||||||
|  |  | ||||||
| 			arg = xcalloc(1, sizeof *arg); | 			arg = xcalloc(1, sizeof *arg); | ||||||
| 			arg->type = CMD_PARSE_STRING; | 			arg->type = CMD_PARSE_STRING; | ||||||
| 			arg->string = xstrdup($2); | 			arg->string = $2; | ||||||
| 			TAILQ_INSERT_HEAD(&$$->arguments, arg, entry); | 			TAILQ_INSERT_HEAD(&$$->arguments, arg, entry); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -543,13 +543,13 @@ argument	: TOKEN | |||||||
| 		{ | 		{ | ||||||
| 			$$ = xcalloc(1, sizeof *$$); | 			$$ = xcalloc(1, sizeof *$$); | ||||||
| 			$$->type = CMD_PARSE_STRING; | 			$$->type = CMD_PARSE_STRING; | ||||||
| 			$$->string = xstrdup($1); | 			$$->string = $1; | ||||||
| 		} | 		} | ||||||
| 		| EQUALS | 		| EQUALS | ||||||
| 		{ | 		{ | ||||||
| 			$$ = xcalloc(1, sizeof *$$); | 			$$ = xcalloc(1, sizeof *$$); | ||||||
| 			$$->type = CMD_PARSE_STRING; | 			$$->type = CMD_PARSE_STRING; | ||||||
| 			$$->string = xstrdup($1); | 			$$->string = $1; | ||||||
| 		} | 		} | ||||||
| 		| '{' argument_statements | 		| '{' argument_statements | ||||||
| 		{ | 		{ | ||||||
| @@ -817,7 +817,6 @@ cmd_parse_build_command(struct cmd_parse_command *cmd, | |||||||
| 				goto out; | 				goto out; | ||||||
| 			values[count].type = ARGS_COMMANDS; | 			values[count].type = ARGS_COMMANDS; | ||||||
| 			values[count].cmdlist = pr->cmdlist; | 			values[count].cmdlist = pr->cmdlist; | ||||||
| 			values[count].cmdlist->references++; |  | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 		count++; | 		count++; | ||||||
|   | |||||||
| @@ -66,6 +66,7 @@ static void | |||||||
| cmd_source_file_complete(struct client *c, struct cmd_source_file_data *cdata) | cmd_source_file_complete(struct client *c, struct cmd_source_file_data *cdata) | ||||||
| { | { | ||||||
| 	struct cmdq_item	*new_item; | 	struct cmdq_item	*new_item; | ||||||
|  | 	u_int			 i; | ||||||
|  |  | ||||||
| 	if (cfg_finished) { | 	if (cfg_finished) { | ||||||
| 		if (cdata->retval == CMD_RETURN_ERROR && | 		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); | 		cmdq_insert_after(cdata->after, new_item); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	for (i = 0; i < cdata->nfiles; i++) | ||||||
|  | 		free(cdata->files[i]); | ||||||
| 	free(cdata->files); | 	free(cdata->files); | ||||||
| 	free(cdata); | 	free(cdata); | ||||||
| } | } | ||||||
| @@ -177,6 +180,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) | |||||||
| 				cmdq_error(item, "%s: %s", path, error); | 				cmdq_error(item, "%s: %s", path, error); | ||||||
| 				retval = CMD_RETURN_ERROR; | 				retval = CMD_RETURN_ERROR; | ||||||
| 			} | 			} | ||||||
|  | 			globfree(&g); | ||||||
| 			free(pattern); | 			free(pattern); | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
| @@ -184,6 +188,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) | |||||||
|  |  | ||||||
| 		for (j = 0; j < g.gl_pathc; j++) | 		for (j = 0; j < g.gl_pathc; j++) | ||||||
| 			cmd_source_file_add(cdata, g.gl_pathv[j]); | 			cmd_source_file_add(cdata, g.gl_pathv[j]); | ||||||
|  | 		globfree(&g); | ||||||
| 	} | 	} | ||||||
| 	free(expanded); | 	free(expanded); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -187,6 +187,7 @@ key_bindings_add(const char *name, key_code key, const char *note, int repeat, | |||||||
| { | { | ||||||
| 	struct key_table	*table; | 	struct key_table	*table; | ||||||
| 	struct key_binding	*bd; | 	struct key_binding	*bd; | ||||||
|  | 	char			*s; | ||||||
|  |  | ||||||
| 	table = key_bindings_get_table(name, 1); | 	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->flags |= KEY_BINDING_REPEAT; | ||||||
| 	bd->cmdlist = cmdlist; | 	bd->cmdlist = cmdlist; | ||||||
|  |  | ||||||
|  | 	s = cmd_list_print(bd->cmdlist, 0); | ||||||
| 	log_debug("%s: %#llx %s = %s", __func__, bd->key, | 	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 | void | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								spawn.c
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								spawn.c
									
									
									
									
									
								
							| @@ -179,6 +179,7 @@ spawn_window(struct spawn_context *sc, char **cause) | |||||||
|  |  | ||||||
| 	/* Set the name of the new window. */ | 	/* Set the name of the new window. */ | ||||||
| 	if (~sc->flags & SPAWN_RESPAWN) { | 	if (~sc->flags & SPAWN_RESPAWN) { | ||||||
|  | 		free(w->name); | ||||||
| 		if (sc->name != NULL) { | 		if (sc->name != NULL) { | ||||||
| 			w->name = format_single(item, sc->name, c, s, NULL, | 			w->name = format_single(item, sc->name, c, s, NULL, | ||||||
| 			    NULL); | 			    NULL); | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								tmux.c
									
									
									
									
									
								
							| @@ -211,6 +211,7 @@ make_label(const char *label, char **cause) | |||||||
| 	free(paths); | 	free(paths); | ||||||
|  |  | ||||||
| 	xasprintf(&base, "%s/tmux-%ld", path, (long)uid); | 	xasprintf(&base, "%s/tmux-%ld", path, (long)uid); | ||||||
|  | 	free(path); | ||||||
| 	if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) { | 	if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) { | ||||||
| 		xasprintf(cause, "couldn't create directory %s (%s)", base, | 		xasprintf(cause, "couldn't create directory %s (%s)", base, | ||||||
| 		    strerror(errno)); | 		    strerror(errno)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 nicm
					nicm