mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Sync OpenBSD patchset 1150:
xfree is not particularly helpful, remove it. From Thomas Adam.
This commit is contained in:
		
							
								
								
									
										20
									
								
								arguments.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								arguments.c
									
									
									
									
									
								
							| @@ -68,15 +68,14 @@ args_parse(const char *template, int argc, char **argv) | |||||||
| 		if (opt < 0 || opt >= SCHAR_MAX) | 		if (opt < 0 || opt >= SCHAR_MAX) | ||||||
| 			continue; | 			continue; | ||||||
| 		if (opt == '?' || (ptr = strchr(template, opt)) == NULL) { | 		if (opt == '?' || (ptr = strchr(template, opt)) == NULL) { | ||||||
| 			xfree(args->flags); | 			free(args->flags); | ||||||
| 			xfree(args); | 			free(args); | ||||||
| 			return (NULL); | 			return (NULL); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		bit_set(args->flags, opt); | 		bit_set(args->flags, opt); | ||||||
| 		if (ptr[1] == ':') { | 		if (ptr[1] == ':') { | ||||||
| 			if (args->values[opt] != NULL) | 			free(args->values[opt]); | ||||||
| 				xfree(args->values[opt]); |  | ||||||
| 			args->values[opt] = xstrdup(optarg); | 			args->values[opt] = xstrdup(optarg); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -97,13 +96,11 @@ args_free(struct args *args) | |||||||
|  |  | ||||||
| 	cmd_free_argv(args->argc, args->argv); | 	cmd_free_argv(args->argc, args->argv); | ||||||
|  |  | ||||||
| 	for (i = 0; i < SCHAR_MAX; i++) { | 	for (i = 0; i < SCHAR_MAX; i++) | ||||||
| 		if (args->values[i] != NULL) | 		free(args->values[i]); | ||||||
| 			xfree(args->values[i]); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	xfree(args->flags); | 	free(args->flags); | ||||||
| 	xfree(args); | 	free(args); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Print a set of arguments. */ | /* Print a set of arguments. */ | ||||||
| @@ -182,8 +179,7 @@ args_has(struct args *args, u_char ch) | |||||||
| void | void | ||||||
| args_set(struct args *args, u_char ch, const char *value) | args_set(struct args *args, u_char ch, const char *value) | ||||||
| { | { | ||||||
| 	if (args->values[ch] != NULL) | 	free(args->values[ch]); | ||||||
| 		xfree(args->values[ch]); |  | ||||||
| 	if (value != NULL) | 	if (value != NULL) | ||||||
| 		args->values[ch] = xstrdup(value); | 		args->values[ch] = xstrdup(value); | ||||||
| 	else | 	else | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								array.h
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								array.h
									
									
									
									
									
								
							| @@ -109,13 +109,12 @@ | |||||||
| } while (0) | } while (0) | ||||||
|  |  | ||||||
| #define ARRAY_FREE(a) do {						\ | #define ARRAY_FREE(a) do {						\ | ||||||
| 	if ((a)->list != NULL)						\ | 	free((a)->list);						\ | ||||||
| 		xfree((a)->list);					\ |  | ||||||
| 	ARRAY_INIT(a);							\ | 	ARRAY_INIT(a);							\ | ||||||
| } while (0) | } while (0) | ||||||
| #define ARRAY_FREEALL(a) do {						\ | #define ARRAY_FREEALL(a) do {						\ | ||||||
| 	ARRAY_FREE(a);							\ | 	ARRAY_FREE(a);							\ | ||||||
| 	xfree(a);							\ | 	free(a);							\ | ||||||
| } while (0) | } while (0) | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								cfg.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								cfg.c
									
									
									
									
									
								
							| @@ -21,6 +21,7 @@ | |||||||
|  |  | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -117,14 +118,14 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes) | |||||||
| 		line = NULL; | 		line = NULL; | ||||||
|  |  | ||||||
| 		if (cmd_string_parse(buf, &cmdlist, &cause) != 0) { | 		if (cmd_string_parse(buf, &cmdlist, &cause) != 0) { | ||||||
| 			xfree(buf); | 			free(buf); | ||||||
| 			if (cause == NULL) | 			if (cause == NULL) | ||||||
| 				continue; | 				continue; | ||||||
| 			cfg_add_cause(causes, "%s: %u: %s", path, n, cause); | 			cfg_add_cause(causes, "%s: %u: %s", path, n, cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			continue; | 			continue; | ||||||
| 		} else | 		} else | ||||||
| 			xfree(buf); | 			free(buf); | ||||||
| 		if (cmdlist == NULL) | 		if (cmdlist == NULL) | ||||||
| 			continue; | 			continue; | ||||||
| 		cfg_cause = NULL; | 		cfg_cause = NULL; | ||||||
| @@ -150,13 +151,13 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes) | |||||||
| 		if (cfg_cause != NULL) { | 		if (cfg_cause != NULL) { | ||||||
| 			cfg_add_cause( | 			cfg_add_cause( | ||||||
| 			    causes, "%s: %d: %s", path, n, cfg_cause); | 			    causes, "%s: %d: %s", path, n, cfg_cause); | ||||||
| 			xfree(cfg_cause); | 			free(cfg_cause); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	if (line != NULL) { | 	if (line != NULL) { | ||||||
| 		cfg_add_cause(causes, | 		cfg_add_cause(causes, | ||||||
| 		    "%s: %d: line continuation at end of file", path, n); | 		    "%s: %d: line continuation at end of file", path, n); | ||||||
| 		xfree(line); | 		free(line); | ||||||
| 	} | 	} | ||||||
| 	fclose(f); | 	fclose(f); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								client.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								client.c
									
									
									
									
									
								
							| @@ -122,7 +122,7 @@ retry: | |||||||
| 		if (unlink(path) != 0 && errno != ENOENT) | 		if (unlink(path) != 0 && errno != ENOENT) | ||||||
| 			return (-1); | 			return (-1); | ||||||
| 		fd = server_start(lockfd, lockfile); | 		fd = server_start(lockfd, lockfile); | ||||||
| 		xfree(lockfile); | 		free(lockfile); | ||||||
| 		close(lockfd); | 		close(lockfd); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -18,6 +18,8 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -81,7 +83,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	} else { | 	} else { | ||||||
| 		if (server_client_open(ctx->cmdclient, s, &cause) != 0) { | 		if (server_client_open(ctx->cmdclient, s, &cause) != 0) { | ||||||
| 			ctx->error(ctx, "open terminal failed: %s", cause); | 			ctx->error(ctx, "open terminal failed: %s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			return (-1); | 			return (-1); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -74,7 +75,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, &cause); | 	cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, &cause); | ||||||
| 	if (cmdlist == NULL) { | 	if (cmdlist == NULL) { | ||||||
| 		ctx->error(ctx, "%s", cause); | 		ctx->error(ctx, "%s", cause); | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	w->active = wp; | 	w->active = wp; | ||||||
| 	name = default_window_name(w); | 	name = default_window_name(w); | ||||||
| 	window_set_name(w, name); | 	window_set_name(w, name); | ||||||
| 	xfree(name); | 	free(name); | ||||||
| 	layout_init(w); | 	layout_init(w); | ||||||
|  |  | ||||||
| 	base_idx = options_get_number(&s->options, "base-index"); | 	base_idx = options_get_number(&s->options, "base-index"); | ||||||
| @@ -106,7 +106,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
|  |  | ||||||
| 		cp = format_expand(ft, template); | 		cp = format_expand(ft, template); | ||||||
| 		ctx->print(ctx, "%s", cp); | 		ctx->print(ctx, "%s", cp); | ||||||
| 		xfree(cp); | 		free(cp); | ||||||
|  |  | ||||||
| 		format_free(ft); | 		format_free(ft); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -62,7 +62,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause); | 	n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause); | ||||||
| 	if (cause != NULL) { | 	if (cause != NULL) { | ||||||
| 		top = gd->hsize; | 		top = gd->hsize; | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 	} else if (n < 0 && (u_int) -n > gd->hsize) | 	} else if (n < 0 && (u_int) -n > gd->hsize) | ||||||
| 		top = 0; | 		top = 0; | ||||||
| 	else | 	else | ||||||
| @@ -73,7 +73,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause); | 	n = args_strtonum(args, 'E', INT_MIN, SHRT_MAX, &cause); | ||||||
| 	if (cause != NULL) { | 	if (cause != NULL) { | ||||||
| 		bottom = gd->hsize + gd->sy - 1; | 		bottom = gd->hsize + gd->sy - 1; | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 	} else if (n < 0 && (u_int) -n > gd->hsize) | 	} else if (n < 0 && (u_int) -n > gd->hsize) | ||||||
| 		bottom = 0; | 		bottom = 0; | ||||||
| 	else | 	else | ||||||
| @@ -96,7 +96,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	       len += linelen; | 	       len += linelen; | ||||||
| 	       buf[len++] = '\n'; | 	       buf[len++] = '\n'; | ||||||
|  |  | ||||||
| 	       xfree(line); | 	       free(line); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	limit = options_get_number(&global_options, "buffer-limit"); | 	limit = options_get_number(&global_options, "buffer-limit"); | ||||||
| @@ -109,14 +109,14 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | 	buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | ||||||
| 	if (cause != NULL) { | 	if (cause != NULL) { | ||||||
| 		ctx->error(ctx, "buffer %s", cause); | 		ctx->error(ctx, "buffer %s", cause); | ||||||
| 		xfree(buf); | 		free(buf); | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (paste_replace(&global_buffers, buffer, buf, len) != 0) { | 	if (paste_replace(&global_buffers, buffer, buf, len) != 0) { | ||||||
| 		ctx->error(ctx, "no buffer %d", buffer); | 		ctx->error(ctx, "no buffer %d", buffer); | ||||||
| 		xfree(buf); | 		free(buf); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
|  | #include <stdlib.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
|  |  | ||||||
| @@ -86,11 +87,11 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
|  |  | ||||||
| 		xasprintf(&action_data, "%u", idx - 1); | 		xasprintf(&action_data, "%u", idx - 1); | ||||||
| 		cdata->command = cmd_template_replace(action, action_data, 1); | 		cdata->command = cmd_template_replace(action, action_data, 1); | ||||||
| 		xfree(action_data); | 		free(action_data); | ||||||
|  |  | ||||||
| 		window_choose_add(wl->window->active, cdata); | 		window_choose_add(wl->window->active, cdata); | ||||||
| 	} | 	} | ||||||
| 	xfree(action); | 	free(action); | ||||||
|  |  | ||||||
| 	window_choose_ready(wl->window->active, | 	window_choose_ready(wl->window->active, | ||||||
| 	    0, cmd_choose_buffer_callback, cmd_choose_buffer_free); | 	    0, cmd_choose_buffer_callback, cmd_choose_buffer_free); | ||||||
| @@ -119,7 +120,7 @@ cmd_choose_buffer_free(struct window_choose_data *data) | |||||||
|  |  | ||||||
| 	cdata->client->references--; | 	cdata->client->references--; | ||||||
|  |  | ||||||
| 	xfree(cdata->command); | 	free(cdata->command); | ||||||
| 	xfree(cdata->ft_template); | 	free(cdata->ft_template); | ||||||
| 	xfree(cdata); | 	free(cdata); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
|  | #include <stdlib.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
|  |  | ||||||
| @@ -98,7 +99,7 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
|  |  | ||||||
| 		window_choose_add(wl->window->active, cdata); | 		window_choose_add(wl->window->active, cdata); | ||||||
| 	} | 	} | ||||||
| 	xfree(action); | 	free(action); | ||||||
|  |  | ||||||
| 	window_choose_ready(wl->window->active, | 	window_choose_ready(wl->window->active, | ||||||
| 	    cur, cmd_choose_client_callback, cmd_choose_client_free); | 	    cur, cmd_choose_client_callback, cmd_choose_client_free); | ||||||
| @@ -133,8 +134,8 @@ cmd_choose_client_free(struct window_choose_data *cdata) | |||||||
|  |  | ||||||
| 	cdata->client->references--; | 	cdata->client->references--; | ||||||
|  |  | ||||||
| 	xfree(cdata->ft_template); | 	free(cdata->ft_template); | ||||||
| 	xfree(cdata->command); | 	free(cdata->command); | ||||||
| 	format_free(cdata->ft); | 	format_free(cdata->ft); | ||||||
| 	xfree(cdata); | 	free(cdata); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
|  | #include <stdlib.h> | ||||||
|  |  | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| @@ -206,7 +207,7 @@ windows_only: | |||||||
| 				ctx, s2, wm, final_win_template, | 				ctx, s2, wm, final_win_template, | ||||||
| 				final_win_action, idx_ses); | 				final_win_action, idx_ses); | ||||||
|  |  | ||||||
| 			xfree(final_win_action); | 			free(final_win_action); | ||||||
| 		} | 		} | ||||||
| 		/* | 		/* | ||||||
| 		 * If we're just drawing windows, don't consider moving on to | 		 * If we're just drawing windows, don't consider moving on to | ||||||
| @@ -215,8 +216,7 @@ windows_only: | |||||||
| 		if (wflag && !sflag) | 		if (wflag && !sflag) | ||||||
| 			break; | 			break; | ||||||
| 	} | 	} | ||||||
| 	if (final_win_template != NULL) | 	free(final_win_template); | ||||||
| 		xfree(final_win_template); |  | ||||||
|  |  | ||||||
| 	window_choose_ready(wl->window->active, cur_win, | 	window_choose_ready(wl->window->active, cur_win, | ||||||
| 		cmd_choose_tree_callback, cmd_choose_tree_free); | 		cmd_choose_tree_callback, cmd_choose_tree_free); | ||||||
| @@ -242,10 +242,10 @@ cmd_choose_tree_free(struct window_choose_data *cdata) | |||||||
| 	cdata->session->references--; | 	cdata->session->references--; | ||||||
| 	cdata->client->references--; | 	cdata->client->references--; | ||||||
|  |  | ||||||
| 	xfree(cdata->ft_template); | 	free(cdata->ft_template); | ||||||
| 	xfree(cdata->command); | 	free(cdata->command); | ||||||
| 	format_free(cdata->ft); | 	format_free(cdata->ft); | ||||||
| 	xfree(cdata); | 	free(cdata); | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
|  |  | ||||||
| @@ -138,7 +139,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
|  |  | ||||||
| 	status_prompt_set(c, prompt, input, cmd_command_prompt_callback, | 	status_prompt_set(c, prompt, input, cmd_command_prompt_callback, | ||||||
| 	    cmd_command_prompt_free, cdata, 0); | 	    cmd_command_prompt_free, cdata, 0); | ||||||
| 	xfree(prompt); | 	free(prompt); | ||||||
|  |  | ||||||
| 	return (0); | 	return (0); | ||||||
| } | } | ||||||
| @@ -157,7 +158,7 @@ cmd_command_prompt_callback(void *data, const char *s) | |||||||
| 		return (0); | 		return (0); | ||||||
|  |  | ||||||
| 	new_template = cmd_template_replace(cdata->template, s, cdata->idx); | 	new_template = cmd_template_replace(cdata->template, s, cdata->idx); | ||||||
| 	xfree(cdata->template); | 	free(cdata->template); | ||||||
| 	cdata->template = new_template; | 	cdata->template = new_template; | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| @@ -169,7 +170,7 @@ cmd_command_prompt_callback(void *data, const char *s) | |||||||
| 		input = strsep(&cdata->next_input, ","); | 		input = strsep(&cdata->next_input, ","); | ||||||
| 		status_prompt_update(c, prompt, input); | 		status_prompt_update(c, prompt, input); | ||||||
|  |  | ||||||
| 		xfree(prompt); | 		free(prompt); | ||||||
| 		cdata->idx++; | 		cdata->idx++; | ||||||
| 		return (1); | 		return (1); | ||||||
| 	} | 	} | ||||||
| @@ -178,7 +179,7 @@ cmd_command_prompt_callback(void *data, const char *s) | |||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			*cause = toupper((u_char) *cause); | 			*cause = toupper((u_char) *cause); | ||||||
| 			status_message_set(c, "%s", cause); | 			status_message_set(c, "%s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 		} | 		} | ||||||
| 		return (0); | 		return (0); | ||||||
| 	} | 	} | ||||||
| @@ -205,11 +206,8 @@ cmd_command_prompt_free(void *data) | |||||||
| { | { | ||||||
| 	struct cmd_command_prompt_cdata	*cdata = data; | 	struct cmd_command_prompt_cdata	*cdata = data; | ||||||
|  |  | ||||||
| 	if (cdata->inputs != NULL) | 	free(cdata->inputs); | ||||||
| 		xfree(cdata->inputs); | 	free(cdata->prompts); | ||||||
| 	if (cdata->prompts != NULL) | 	free(cdata->template); | ||||||
| 		xfree(cdata->prompts); | 	free(cdata); | ||||||
| 	if (cdata->template != NULL) |  | ||||||
| 		xfree(cdata->template); |  | ||||||
| 	xfree(cdata); |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -87,7 +88,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		ptr = copy = xstrdup(args->argv[0]); | 		ptr = copy = xstrdup(args->argv[0]); | ||||||
| 		cmd = strsep(&ptr, " \t"); | 		cmd = strsep(&ptr, " \t"); | ||||||
| 		xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd); | 		xasprintf(&new_prompt, "Confirm '%s'? (y/n) ", cmd); | ||||||
| 		xfree(copy); | 		free(copy); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	cdata = xmalloc(sizeof *cdata); | 	cdata = xmalloc(sizeof *cdata); | ||||||
| @@ -97,7 +98,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	    cmd_confirm_before_callback, cmd_confirm_before_free, cdata, | 	    cmd_confirm_before_callback, cmd_confirm_before_free, cdata, | ||||||
| 	    PROMPT_SINGLE); | 	    PROMPT_SINGLE); | ||||||
|  |  | ||||||
| 	xfree(new_prompt); | 	free(new_prompt); | ||||||
| 	return (1); | 	return (1); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -119,7 +120,7 @@ cmd_confirm_before_callback(void *data, const char *s) | |||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			*cause = toupper((u_char) *cause); | 			*cause = toupper((u_char) *cause); | ||||||
| 			status_message_set(c, "%s", cause); | 			status_message_set(c, "%s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 		} | 		} | ||||||
| 		return (0); | 		return (0); | ||||||
| 	} | 	} | ||||||
| @@ -144,7 +145,6 @@ cmd_confirm_before_free(void *data) | |||||||
| { | { | ||||||
| 	struct cmd_confirm_before_data	*cdata = data; | 	struct cmd_confirm_before_data	*cdata = data; | ||||||
|  |  | ||||||
| 	if (cdata->cmd != NULL) | 	free(cdata->cmd); | ||||||
| 		xfree(cdata->cmd); | 	free(cdata); | ||||||
| 	xfree(cdata); |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -53,7 +53,7 @@ cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | 	buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | ||||||
| 	if (cause != NULL) { | 	if (cause != NULL) { | ||||||
| 		ctx->error(ctx, "buffer %s", cause); | 		ctx->error(ctx, "buffer %s", cause); | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -93,7 +94,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	else | 	else | ||||||
| 		status_message_set(c, "%s", msg); | 		status_message_set(c, "%s", msg); | ||||||
|  |  | ||||||
| 	xfree(msg); | 	free(msg); | ||||||
| 	format_free(ft); | 	format_free(ft); | ||||||
| 	return (0); | 	return (0); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
| #include <fnmatch.h> | #include <fnmatch.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -134,7 +135,7 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 					xasprintf(&sctx, | 					xasprintf(&sctx, | ||||||
| 					    "pane %u line %u: \"%s\"", i - 1, | 					    "pane %u line %u: \"%s\"", i - 1, | ||||||
| 					    line + 1, sres); | 					    line + 1, sres); | ||||||
| 					xfree(sres); | 					free(sres); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| @@ -143,7 +144,7 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	xfree(searchstr); | 	free(searchstr); | ||||||
|  |  | ||||||
| 	if (ARRAY_LENGTH(&list_idx) == 0) { | 	if (ARRAY_LENGTH(&list_idx) == 0) { | ||||||
| 		ctx->error(ctx, "no windows matching: %s", str); | 		ctx->error(ctx, "no windows matching: %s", str); | ||||||
| @@ -217,7 +218,7 @@ cmd_find_window_free(struct window_choose_data *cdata) | |||||||
|  |  | ||||||
| 	cdata->session->references--; | 	cdata->session->references--; | ||||||
|  |  | ||||||
| 	xfree(cdata->ft_template); | 	free(cdata->ft_template); | ||||||
| 	format_free(cdata->ft); | 	format_free(cdata->ft); | ||||||
| 	xfree(cdata); | 	free(cdata); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
| #include <sys/wait.h> | #include <sys/wait.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -91,7 +92,7 @@ cmd_if_shell_callback(struct job *job) | |||||||
| 	if (cmd_string_parse(cmd, &cmdlist, &cause) != 0) { | 	if (cmd_string_parse(cmd, &cmdlist, &cause) != 0) { | ||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			ctx->error(ctx, "%s", cause); | 			ctx->error(ctx, "%s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 		} | 		} | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| @@ -115,8 +116,7 @@ cmd_if_shell_free(void *data) | |||||||
| 	if (ctx->curclient != NULL) | 	if (ctx->curclient != NULL) | ||||||
| 		ctx->curclient->references--; | 		ctx->curclient->references--; | ||||||
|  |  | ||||||
| 	if (cdata->cmd_else != NULL) | 	free(cdata->cmd_else); | ||||||
| 		xfree(cdata->cmd_else); | 	free(cdata->cmd_if); | ||||||
| 	xfree(cdata->cmd_if); | 	free(cdata); | ||||||
| 	xfree(cdata); |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -115,14 +115,14 @@ join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window) | |||||||
| 		size = args_strtonum(args, 'l', 0, INT_MAX, &cause); | 		size = args_strtonum(args, 'l', 0, INT_MAX, &cause); | ||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			ctx->error(ctx, "size %s", cause); | 			ctx->error(ctx, "size %s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			return (-1); | 			return (-1); | ||||||
| 		} | 		} | ||||||
| 	} else if (args_has(args, 'p')) { | 	} else if (args_has(args, 'p')) { | ||||||
| 		percentage = args_strtonum(args, 'p', 0, 100, &cause); | 		percentage = args_strtonum(args, 'p', 0, 100, &cause); | ||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			ctx->error(ctx, "percentage %s", cause); | 			ctx->error(ctx, "percentage %s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			return (-1); | 			return (-1); | ||||||
| 		} | 		} | ||||||
| 		if (type == LAYOUT_TOPBOTTOM) | 		if (type == LAYOUT_TOPBOTTOM) | ||||||
|   | |||||||
| @@ -56,7 +56,7 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	dflag = args_has(self->args, 'd'); | 	dflag = args_has(self->args, 'd'); | ||||||
| 	if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) { | 	if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) { | ||||||
| 		ctx->error(ctx, "can't link window: %s", cause); | 		ctx->error(ctx, "can't link window: %s", cause); | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
| 	recalculate_sizes(); | 	recalculate_sizes(); | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -60,7 +61,7 @@ cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx) | |||||||
|  |  | ||||||
| 		line = format_expand(ft, template); | 		line = format_expand(ft, template); | ||||||
| 		ctx->print(ctx, "%s", line); | 		ctx->print(ctx, "%s", line); | ||||||
| 		xfree(line); | 		free(line); | ||||||
|  |  | ||||||
| 		format_free(ft); | 		format_free(ft); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
|  |  | ||||||
| @@ -76,7 +77,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
|  |  | ||||||
| 		line = format_expand(ft, template); | 		line = format_expand(ft, template); | ||||||
| 		ctx->print(ctx, "%s", line); | 		ctx->print(ctx, "%s", line); | ||||||
| 		xfree(line); | 		free(line); | ||||||
|  |  | ||||||
| 		format_free(ft); | 		format_free(ft); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -135,7 +136,7 @@ cmd_list_panes_window(struct cmd *self, | |||||||
|  |  | ||||||
| 		line = format_expand(ft, template); | 		line = format_expand(ft, template); | ||||||
| 		ctx->print(ctx, "%s", line); | 		ctx->print(ctx, "%s", line); | ||||||
| 		xfree(line); | 		free(line); | ||||||
|  |  | ||||||
| 		format_free(ft); | 		format_free(ft); | ||||||
| 		n++; | 		n++; | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
|  |  | ||||||
| @@ -60,7 +61,7 @@ cmd_list_sessions_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
|  |  | ||||||
| 		line = format_expand(ft, template); | 		line = format_expand(ft, template); | ||||||
| 		ctx->print(ctx, "%s", line); | 		ctx->print(ctx, "%s", line); | ||||||
| 		xfree(line); | 		free(line); | ||||||
|  |  | ||||||
| 		format_free(ft); | 		format_free(ft); | ||||||
| 		n++; | 		n++; | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -103,7 +104,7 @@ cmd_list_windows_session( | |||||||
|  |  | ||||||
| 		line = format_expand(ft, template); | 		line = format_expand(ft, template); | ||||||
| 		ctx->print(ctx, "%s", line); | 		ctx->print(ctx, "%s", line); | ||||||
| 		xfree(line); | 		free(line); | ||||||
|  |  | ||||||
| 		format_free(ft); | 		format_free(ft); | ||||||
| 		n++; | 		n++; | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -139,7 +140,7 @@ cmd_list_free(struct cmd_list *cmdlist) | |||||||
| 		TAILQ_REMOVE(&cmdlist->list, cmd, qentry); | 		TAILQ_REMOVE(&cmdlist->list, cmd, qentry); | ||||||
| 		cmd_free(cmd); | 		cmd_free(cmd); | ||||||
| 	} | 	} | ||||||
| 	xfree(cmdlist); | 	free(cmdlist); | ||||||
| } | } | ||||||
|  |  | ||||||
| size_t | size_t | ||||||
|   | |||||||
| @@ -62,7 +62,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | 		buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | ||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			ctx->error(ctx, "buffer %s", cause); | 			ctx->error(ctx, "buffer %s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			return (-1); | 			return (-1); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -76,7 +76,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		    buffer_ptr, &cause); | 		    buffer_ptr, &cause); | ||||||
| 		if (error != 0) { | 		if (error != 0) { | ||||||
| 			ctx->error(ctx, "%s: %s", path, cause); | 			ctx->error(ctx, "%s: %s", path, cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			return (-1); | 			return (-1); | ||||||
| 		} | 		} | ||||||
| 		return (1); | 		return (1); | ||||||
| @@ -127,15 +127,14 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	} | 	} | ||||||
| 	if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) { | 	if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) { | ||||||
| 		ctx->error(ctx, "no buffer %d", buffer); | 		ctx->error(ctx, "no buffer %d", buffer); | ||||||
| 		xfree(pdata); | 		free(pdata); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return (0); | 	return (0); | ||||||
|  |  | ||||||
| error: | error: | ||||||
| 	if (pdata != NULL) | 	free(pdata); | ||||||
| 		xfree(pdata); |  | ||||||
| 	if (f != NULL) | 	if (f != NULL) | ||||||
| 		fclose(f); | 		fclose(f); | ||||||
| 	return (-1); | 	return (-1); | ||||||
| @@ -158,7 +157,7 @@ cmd_load_buffer_callback(struct client *c, int closed, void *data) | |||||||
|  |  | ||||||
| 	psize = EVBUFFER_LENGTH(c->stdin_data); | 	psize = EVBUFFER_LENGTH(c->stdin_data); | ||||||
| 	if (psize == 0 || (pdata = malloc(psize + 1)) == NULL) { | 	if (psize == 0 || (pdata = malloc(psize + 1)) == NULL) { | ||||||
| 		xfree(data); | 		free(data); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	memcpy(pdata, EVBUFFER_DATA(c->stdin_data), psize); | 	memcpy(pdata, EVBUFFER_DATA(c->stdin_data), psize); | ||||||
| @@ -174,5 +173,5 @@ cmd_load_buffer_callback(struct client *c, int closed, void *data) | |||||||
| 		server_push_stderr(c); | 		server_push_stderr(c); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(data); | 	free(data); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -66,7 +66,7 @@ cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	dflag = args_has(self->args, 'd'); | 	dflag = args_has(self->args, 'd'); | ||||||
| 	if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) { | 	if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) { | ||||||
| 		ctx->error(ctx, "can't move window: %s", cause); | 		ctx->error(ctx, "can't move window: %s", cause); | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
| 	server_unlink_window(src, wl); | 	server_unlink_window(src, wl); | ||||||
|   | |||||||
| @@ -130,7 +130,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	if (!detached && ctx->cmdclient != NULL) { | 	if (!detached && ctx->cmdclient != NULL) { | ||||||
| 		if (server_client_open(ctx->cmdclient, NULL, &cause) != 0) { | 		if (server_client_open(ctx->cmdclient, NULL, &cause) != 0) { | ||||||
| 			ctx->error(ctx, "open terminal failed: %s", cause); | 			ctx->error(ctx, "open terminal failed: %s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			return (-1); | 			return (-1); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -201,7 +201,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	s = session_create(newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause); | 	s = session_create(newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause); | ||||||
| 	if (s == NULL) { | 	if (s == NULL) { | ||||||
| 		ctx->error(ctx, "create session failed: %s", cause); | 		ctx->error(ctx, "create session failed: %s", cause); | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
| 	environ_free(&env); | 	environ_free(&env); | ||||||
| @@ -264,7 +264,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) { | 		for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) { | ||||||
| 			cause = ARRAY_ITEM(&cfg_causes, i); | 			cause = ARRAY_ITEM(&cfg_causes, i); | ||||||
| 			window_copy_add(wp, "%s", cause); | 			window_copy_add(wp, "%s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 		} | 		} | ||||||
| 		ARRAY_FREE(&cfg_causes); | 		ARRAY_FREE(&cfg_causes); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -112,7 +112,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause); | 	wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause); | ||||||
| 	if (wl == NULL) { | 	if (wl == NULL) { | ||||||
| 		ctx->error(ctx, "create window failed: %s", cause); | 		ctx->error(ctx, "create window failed: %s", cause); | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
| 	if (!detached) { | 	if (!detached) { | ||||||
| @@ -134,7 +134,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
|  |  | ||||||
| 		cp = format_expand(ft, template); | 		cp = format_expand(ft, template); | ||||||
| 		ctx->print(ctx, "%s", cp); | 		ctx->print(ctx, "%s", cp); | ||||||
| 		xfree(cp); | 		free(cp); | ||||||
|  |  | ||||||
| 		format_free(ft); | 		format_free(ft); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -63,7 +63,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | 		buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | ||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			ctx->error(ctx, "buffer %s", cause); | 			ctx->error(ctx, "buffer %s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			return (-1); | 			return (-1); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -59,7 +59,7 @@ cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		return (-1); | 		return (-1); | ||||||
|  |  | ||||||
| 	RB_REMOVE(sessions, &sessions, s); | 	RB_REMOVE(sessions, &sessions, s); | ||||||
| 	xfree(s->name); | 	free(s->name); | ||||||
| 	s->name = xstrdup(newname); | 	s->name = xstrdup(newname); | ||||||
| 	RB_INSERT(sessions, &sessions, s); | 	RB_INSERT(sessions, &sessions, s); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -79,7 +80,7 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		cmd = NULL; | 		cmd = NULL; | ||||||
| 	if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) { | 	if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) { | ||||||
| 		ctx->error(ctx, "respawn pane failed: %s", cause); | 		ctx->error(ctx, "respawn pane failed: %s", cause); | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 		environ_free(&env); | 		environ_free(&env); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -81,7 +82,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		cmd = NULL; | 		cmd = NULL; | ||||||
| 	if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) { | 	if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) { | ||||||
| 		ctx->error(ctx, "respawn window failed: %s", cause); | 		ctx->error(ctx, "respawn window failed: %s", cause); | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 		environ_free(&env); | 		environ_free(&env); | ||||||
| 		server_destroy_pane(wp); | 		server_destroy_pane(wp); | ||||||
| 		return (-1); | 		return (-1); | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
| #include <sys/wait.h> | #include <sys/wait.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -101,7 +102,7 @@ cmd_run_shell_callback(struct job *job) | |||||||
| 		ctx->print(ctx, "%s", line); | 		ctx->print(ctx, "%s", line); | ||||||
| 		lines++; | 		lines++; | ||||||
|  |  | ||||||
| 		xfree(line); | 		free(line); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	cmd = cdata->cmd; | 	cmd = cdata->cmd; | ||||||
| @@ -119,7 +120,7 @@ cmd_run_shell_callback(struct job *job) | |||||||
| 			ctx->print(ctx, "%s", msg); | 			ctx->print(ctx, "%s", msg); | ||||||
| 		else | 		else | ||||||
| 			ctx->info(ctx, "%s", msg); | 			ctx->info(ctx, "%s", msg); | ||||||
| 		xfree(msg); | 		free(msg); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -136,6 +137,6 @@ cmd_run_shell_free(void *data) | |||||||
| 	if (ctx->curclient != NULL) | 	if (ctx->curclient != NULL) | ||||||
| 		ctx->curclient->references--; | 		ctx->curclient->references--; | ||||||
|  |  | ||||||
| 	xfree(cdata->cmd); | 	free(cdata->cmd); | ||||||
| 	xfree(cdata); | 	free(cdata); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ | |||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
|  |  | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -62,7 +63,7 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | 		buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | ||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			ctx->error(ctx, "buffer %s", cause); | 			ctx->error(ctx, "buffer %s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			return (-1); | 			return (-1); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -60,14 +61,14 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 	buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | 	buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | ||||||
| 	if (cause != NULL) { | 	if (cause != NULL) { | ||||||
| 		ctx->error(ctx, "buffer %s", cause); | 		ctx->error(ctx, "buffer %s", cause); | ||||||
| 		xfree(cause); | 		free(cause); | ||||||
| 		xfree(pdata); | 		free(pdata); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) { | 	if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) { | ||||||
| 		ctx->error(ctx, "no buffer %d", buffer); | 		ctx->error(ctx, "no buffer %d", buffer); | ||||||
| 		xfree(pdata); | 		free(pdata); | ||||||
| 		return (-1); | 		return (-1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -257,7 +257,7 @@ cmd_set_option_string(struct cmd *self, unused struct cmd_ctx *ctx, | |||||||
|  |  | ||||||
| 	o = options_set_string(oo, oe->name, "%s", newval); | 	o = options_set_string(oo, oe->name, "%s", newval); | ||||||
|  |  | ||||||
| 	xfree(newval); | 	free(newval); | ||||||
| 	return (o); | 	return (o); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -18,6 +18,8 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -59,7 +61,7 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | 		buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); | ||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			ctx->error(ctx, "buffer %s", cause); | 			ctx->error(ctx, "buffer %s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			return (-1); | 			return (-1); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -101,9 +103,9 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		buf[len] = '\0'; | 		buf[len] = '\0'; | ||||||
| 		ctx->print(ctx, "%s", buf); | 		ctx->print(ctx, "%s", buf); | ||||||
| 	} | 	} | ||||||
| 	xfree(buf); | 	free(buf); | ||||||
|  |  | ||||||
| 	xfree(in); | 	free(in); | ||||||
|  |  | ||||||
| 	return (0); | 	return (0); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -18,6 +18,8 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -59,13 +61,13 @@ cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		for (i = 0; i < ARRAY_LENGTH(&causes); i++) { | 		for (i = 0; i < ARRAY_LENGTH(&causes); i++) { | ||||||
| 			cause = ARRAY_ITEM(&causes, i); | 			cause = ARRAY_ITEM(&causes, i); | ||||||
| 			window_copy_add(wp, "%s", cause); | 			window_copy_add(wp, "%s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 		} | 		} | ||||||
| 	} else { | 	} else { | ||||||
| 		for (i = 0; i < ARRAY_LENGTH(&causes); i++) { | 		for (i = 0; i < ARRAY_LENGTH(&causes); i++) { | ||||||
| 			cause = ARRAY_ITEM(&causes, i); | 			cause = ARRAY_ITEM(&causes, i); | ||||||
| 			ctx->print(ctx, "%s", cause); | 			ctx->print(ctx, "%s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	ARRAY_FREE(&causes); | 	ARRAY_FREE(&causes); | ||||||
|   | |||||||
| @@ -93,7 +93,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		size = args_strtonum(args, 'l', 0, INT_MAX, &cause); | 		size = args_strtonum(args, 'l', 0, INT_MAX, &cause); | ||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			xasprintf(&new_cause, "size %s", cause); | 			xasprintf(&new_cause, "size %s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			cause = new_cause; | 			cause = new_cause; | ||||||
| 			goto error; | 			goto error; | ||||||
| 		} | 		} | ||||||
| @@ -101,7 +101,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
| 		percentage = args_strtonum(args, 'p', 0, INT_MAX, &cause); | 		percentage = args_strtonum(args, 'p', 0, INT_MAX, &cause); | ||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			xasprintf(&new_cause, "percentage %s", cause); | 			xasprintf(&new_cause, "percentage %s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 			cause = new_cause; | 			cause = new_cause; | ||||||
| 			goto error; | 			goto error; | ||||||
| 		} | 		} | ||||||
| @@ -150,7 +150,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) | |||||||
|  |  | ||||||
| 		cp = format_expand(ft, template); | 		cp = format_expand(ft, template); | ||||||
| 		ctx->print(ctx, "%s", cp); | 		ctx->print(ctx, "%s", cp); | ||||||
| 		xfree(cp); | 		free(cp); | ||||||
|  |  | ||||||
| 		format_free(ft); | 		format_free(ft); | ||||||
| 	} | 	} | ||||||
| @@ -162,6 +162,6 @@ error: | |||||||
| 	if (new_wp != NULL) | 	if (new_wp != NULL) | ||||||
| 		window_remove_pane(w, new_wp); | 		window_remove_pane(w, new_wp); | ||||||
| 	ctx->error(ctx, "create pane failed: %s", cause); | 	ctx->error(ctx, "create pane failed: %s", cause); | ||||||
| 	xfree(cause); | 	free(cause); | ||||||
| 	return (-1); | 	return (-1); | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										27
									
								
								cmd-string.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								cmd-string.c
									
									
									
									
									
								
							| @@ -87,7 +87,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause) | |||||||
| 			buf = xrealloc(buf, 1, len + strlen(t) + 1); | 			buf = xrealloc(buf, 1, len + strlen(t) + 1); | ||||||
| 			strlcpy(buf + len, t, strlen(t) + 1); | 			strlcpy(buf + len, t, strlen(t) + 1); | ||||||
| 			len += strlen(t); | 			len += strlen(t); | ||||||
| 			xfree(t); | 			free(t); | ||||||
| 			break; | 			break; | ||||||
| 		case '"': | 		case '"': | ||||||
| 			if ((t = cmd_string_string(s, &p, '"', 1)) == NULL) | 			if ((t = cmd_string_string(s, &p, '"', 1)) == NULL) | ||||||
| @@ -95,7 +95,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause) | |||||||
| 			buf = xrealloc(buf, 1, len + strlen(t) + 1); | 			buf = xrealloc(buf, 1, len + strlen(t) + 1); | ||||||
| 			strlcpy(buf + len, t, strlen(t) + 1); | 			strlcpy(buf + len, t, strlen(t) + 1); | ||||||
| 			len += strlen(t); | 			len += strlen(t); | ||||||
| 			xfree(t); | 			free(t); | ||||||
| 			break; | 			break; | ||||||
| 		case '$': | 		case '$': | ||||||
| 			if ((t = cmd_string_variable(s, &p)) == NULL) | 			if ((t = cmd_string_variable(s, &p)) == NULL) | ||||||
| @@ -103,7 +103,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause) | |||||||
| 			buf = xrealloc(buf, 1, len + strlen(t) + 1); | 			buf = xrealloc(buf, 1, len + strlen(t) + 1); | ||||||
| 			strlcpy(buf + len, t, strlen(t) + 1); | 			strlcpy(buf + len, t, strlen(t) + 1); | ||||||
| 			len += strlen(t); | 			len += strlen(t); | ||||||
| 			xfree(t); | 			free(t); | ||||||
| 			break; | 			break; | ||||||
| 		case '#': | 		case '#': | ||||||
| 			/* Comment: discard rest of line. */ | 			/* Comment: discard rest of line. */ | ||||||
| @@ -152,7 +152,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause) | |||||||
| 				buf = xrealloc(buf, 1, len + strlen(t) + 1); | 				buf = xrealloc(buf, 1, len + strlen(t) + 1); | ||||||
| 				strlcpy(buf + len, t, strlen(t) + 1); | 				strlcpy(buf + len, t, strlen(t) + 1); | ||||||
| 				len += strlen(t); | 				len += strlen(t); | ||||||
| 				xfree(t); | 				free(t); | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| 			/* FALLTHROUGH */ | 			/* FALLTHROUGH */ | ||||||
| @@ -170,13 +170,12 @@ error: | |||||||
| 	xasprintf(cause, "invalid or unknown command: %s", s); | 	xasprintf(cause, "invalid or unknown command: %s", s); | ||||||
|  |  | ||||||
| out: | out: | ||||||
| 	if (buf != NULL) | 	free(buf); | ||||||
| 		xfree(buf); |  | ||||||
|  |  | ||||||
| 	if (argv != NULL) { | 	if (argv != NULL) { | ||||||
| 		for (i = 0; i < argc; i++) | 		for (i = 0; i < argc; i++) | ||||||
| 			xfree(argv[i]); | 			free(argv[i]); | ||||||
| 		xfree(argv); | 		free(argv); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return (rval); | 	return (rval); | ||||||
| @@ -224,7 +223,7 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc) | |||||||
| 			buf = xrealloc(buf, 1, len + strlen(t) + 1); | 			buf = xrealloc(buf, 1, len + strlen(t) + 1); | ||||||
| 			strlcpy(buf + len, t, strlen(t) + 1); | 			strlcpy(buf + len, t, strlen(t) + 1); | ||||||
| 			len += strlen(t); | 			len += strlen(t); | ||||||
| 			xfree(t); | 			free(t); | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -239,8 +238,7 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc) | |||||||
| 	return (buf); | 	return (buf); | ||||||
|  |  | ||||||
| error: | error: | ||||||
| 	if (buf != NULL) | 	free(buf); | ||||||
| 		xfree(buf); |  | ||||||
| 	return (NULL); | 	return (NULL); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -303,14 +301,13 @@ cmd_string_variable(const char *s, size_t *p) | |||||||
| 	buf[len] = '\0'; | 	buf[len] = '\0'; | ||||||
|  |  | ||||||
| 	envent = environ_find(&global_environ, buf); | 	envent = environ_find(&global_environ, buf); | ||||||
| 	xfree(buf); | 	free(buf); | ||||||
| 	if (envent == NULL) | 	if (envent == NULL) | ||||||
| 		return (xstrdup("")); | 		return (xstrdup("")); | ||||||
| 	return (xstrdup(envent->value)); | 	return (xstrdup(envent->value)); | ||||||
|  |  | ||||||
| error: | error: | ||||||
| 	if (buf != NULL) | 	free(buf); | ||||||
| 		xfree(buf); |  | ||||||
| 	return (NULL); | 	return (NULL); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -334,7 +331,7 @@ cmd_string_expand_tilde(const char *s, size_t *p) | |||||||
| 			return (NULL); | 			return (NULL); | ||||||
| 		if ((pw = getpwnam(username)) != NULL) | 		if ((pw = getpwnam(username)) != NULL) | ||||||
| 			home = pw->pw_dir; | 			home = pw->pw_dir; | ||||||
| 		xfree(username); | 		free(username); | ||||||
| 	} | 	} | ||||||
| 	if (home == NULL) | 	if (home == NULL) | ||||||
| 		return (NULL); | 		return (NULL); | ||||||
|   | |||||||
| @@ -18,6 +18,8 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -100,7 +102,7 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key) | |||||||
| 		while (!RB_EMPTY(mtab->tree)) { | 		while (!RB_EMPTY(mtab->tree)) { | ||||||
| 			mbind = RB_ROOT(mtab->tree); | 			mbind = RB_ROOT(mtab->tree); | ||||||
| 			RB_REMOVE(mode_key_tree, mtab->tree, mbind); | 			RB_REMOVE(mode_key_tree, mtab->tree, mbind); | ||||||
| 			xfree(mbind); | 			free(mbind); | ||||||
| 		} | 		} | ||||||
| 		return (0); | 		return (0); | ||||||
| 	} | 	} | ||||||
| @@ -109,7 +111,7 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key) | |||||||
| 	mtmp.mode = !!args_has(args, 'c'); | 	mtmp.mode = !!args_has(args, 'c'); | ||||||
| 	if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) { | 	if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) { | ||||||
| 		RB_REMOVE(mode_key_tree, mtab->tree, mbind); | 		RB_REMOVE(mode_key_tree, mtab->tree, mbind); | ||||||
| 		xfree(mbind); | 		free(mbind); | ||||||
| 	} | 	} | ||||||
| 	return (0); | 	return (0); | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										43
									
								
								cmd.c
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								cmd.c
									
									
									
									
									
								
							| @@ -197,11 +197,9 @@ cmd_free_argv(int argc, char **argv) | |||||||
|  |  | ||||||
| 	if (argc == 0) | 	if (argc == 0) | ||||||
| 		return; | 		return; | ||||||
| 	for (i = 0; i < argc; i++) { | 	for (i = 0; i < argc; i++) | ||||||
| 		if (argv[i] != NULL) | 		free(argv[i]); | ||||||
| 			xfree(argv[i]); | 	free(argv); | ||||||
| 	} |  | ||||||
| 	xfree(argv); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| struct cmd * | struct cmd * | ||||||
| @@ -290,9 +288,8 @@ cmd_exec(struct cmd *cmd, struct cmd_ctx *ctx) | |||||||
| void | void | ||||||
| cmd_free(struct cmd *cmd) | cmd_free(struct cmd *cmd) | ||||||
| { | { | ||||||
| 	if (cmd->args != NULL) |  | ||||||
| 	args_free(cmd->args); | 	args_free(cmd->args); | ||||||
| 	xfree(cmd); | 	free(cmd); | ||||||
| } | } | ||||||
|  |  | ||||||
| size_t | size_t | ||||||
| @@ -506,7 +503,7 @@ cmd_find_client(struct cmd_ctx *ctx, const char *arg) | |||||||
| 	if (c == NULL) | 	if (c == NULL) | ||||||
| 		ctx->error(ctx, "client not found: %s", tmparg); | 		ctx->error(ctx, "client not found: %s", tmparg); | ||||||
|  |  | ||||||
| 	xfree(tmparg); | 	free(tmparg); | ||||||
| 	return (c); | 	return (c); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -766,7 +763,7 @@ cmd_find_session(struct cmd_ctx *ctx, const char *arg, int prefer_unattached) | |||||||
|  |  | ||||||
| 	/* An empty session name is the current session. */ | 	/* An empty session name is the current session. */ | ||||||
| 	if (*tmparg == '\0') { | 	if (*tmparg == '\0') { | ||||||
| 		xfree(tmparg); | 		free(tmparg); | ||||||
| 		return (cmd_current_session(ctx, prefer_unattached)); | 		return (cmd_current_session(ctx, prefer_unattached)); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -785,7 +782,7 @@ cmd_find_session(struct cmd_ctx *ctx, const char *arg, int prefer_unattached) | |||||||
| 			ctx->error(ctx, "session not found: %s", tmparg); | 			ctx->error(ctx, "session not found: %s", tmparg); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(tmparg); | 	free(tmparg); | ||||||
| 	return (s); | 	return (s); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -860,7 +857,7 @@ cmd_find_window(struct cmd_ctx *ctx, const char *arg, struct session **sp) | |||||||
| 		goto not_found; | 		goto not_found; | ||||||
|  |  | ||||||
| 	if (sessptr != NULL) | 	if (sessptr != NULL) | ||||||
| 		xfree(sessptr); | 		free(sessptr); | ||||||
| 	return (wl); | 	return (wl); | ||||||
|  |  | ||||||
| no_colon: | no_colon: | ||||||
| @@ -898,8 +895,7 @@ no_session: | |||||||
| 		ctx->error(ctx, "multiple sessions: %s", arg); | 		ctx->error(ctx, "multiple sessions: %s", arg); | ||||||
| 	else | 	else | ||||||
| 		ctx->error(ctx, "session not found: %s", arg); | 		ctx->error(ctx, "session not found: %s", arg); | ||||||
| 	if (sessptr != NULL) | 	free(sessptr); | ||||||
| 		xfree(sessptr); |  | ||||||
| 	return (NULL); | 	return (NULL); | ||||||
|  |  | ||||||
| not_found: | not_found: | ||||||
| @@ -907,8 +903,7 @@ not_found: | |||||||
| 		ctx->error(ctx, "multiple windows: %s", arg); | 		ctx->error(ctx, "multiple windows: %s", arg); | ||||||
| 	else | 	else | ||||||
| 		ctx->error(ctx, "window not found: %s", arg); | 		ctx->error(ctx, "window not found: %s", arg); | ||||||
| 	if (sessptr != NULL) | 	free(sessptr); | ||||||
| 		xfree(sessptr); |  | ||||||
| 	return (NULL); | 	return (NULL); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -999,8 +994,7 @@ cmd_find_index(struct cmd_ctx *ctx, const char *arg, struct session **sp) | |||||||
| 	} else if ((idx = cmd_lookup_index(s, winptr, &ambiguous)) == -1) | 	} else if ((idx = cmd_lookup_index(s, winptr, &ambiguous)) == -1) | ||||||
| 		goto invalid_index; | 		goto invalid_index; | ||||||
|  |  | ||||||
| 	if (sessptr != NULL) | 	free(sessptr); | ||||||
| 		xfree(sessptr); |  | ||||||
| 	return (idx); | 	return (idx); | ||||||
|  |  | ||||||
| no_colon: | no_colon: | ||||||
| @@ -1039,8 +1033,7 @@ no_session: | |||||||
| 		ctx->error(ctx, "multiple sessions: %s", arg); | 		ctx->error(ctx, "multiple sessions: %s", arg); | ||||||
| 	else | 	else | ||||||
| 		ctx->error(ctx, "session not found: %s", arg); | 		ctx->error(ctx, "session not found: %s", arg); | ||||||
| 	if (sessptr != NULL) | 	free(sessptr); | ||||||
| 		xfree(sessptr); |  | ||||||
| 	return (-2); | 	return (-2); | ||||||
|  |  | ||||||
| invalid_index: | invalid_index: | ||||||
| @@ -1048,8 +1041,7 @@ invalid_index: | |||||||
| 		goto not_found; | 		goto not_found; | ||||||
| 	ctx->error(ctx, "invalid index: %s", arg); | 	ctx->error(ctx, "invalid index: %s", arg); | ||||||
|  |  | ||||||
| 	if (sessptr != NULL) | 	free(sessptr); | ||||||
| 		xfree(sessptr); |  | ||||||
| 	return (-2); | 	return (-2); | ||||||
|  |  | ||||||
| not_found: | not_found: | ||||||
| @@ -1057,8 +1049,7 @@ not_found: | |||||||
| 		ctx->error(ctx, "multiple windows: %s", arg); | 		ctx->error(ctx, "multiple windows: %s", arg); | ||||||
| 	else | 	else | ||||||
| 		ctx->error(ctx, "window not found: %s", arg); | 		ctx->error(ctx, "window not found: %s", arg); | ||||||
| 	if (sessptr != NULL) | 	free(sessptr); | ||||||
| 		xfree(sessptr); |  | ||||||
| 	return (-2); | 	return (-2); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -1152,7 +1143,7 @@ cmd_find_pane(struct cmd_ctx *ctx, | |||||||
| 			goto lookup_string; | 			goto lookup_string; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(winptr); | 	free(winptr); | ||||||
| 	return (wl); | 	return (wl); | ||||||
|  |  | ||||||
| lookup_string: | lookup_string: | ||||||
| @@ -1162,7 +1153,7 @@ lookup_string: | |||||||
| 		goto error; | 		goto error; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(winptr); | 	free(winptr); | ||||||
| 	return (wl); | 	return (wl); | ||||||
|  |  | ||||||
| no_period: | no_period: | ||||||
| @@ -1188,7 +1179,7 @@ lookup_window: | |||||||
| 	return (wl); | 	return (wl); | ||||||
|  |  | ||||||
| error: | error: | ||||||
| 	xfree(winptr); | 	free(winptr); | ||||||
| 	return (NULL); | 	return (NULL); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
| #include <event.h> | #include <event.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -110,12 +111,12 @@ control_callback(struct client *c, int closed, unused void *data) | |||||||
| 		if (cmd_string_parse(line, &cmdlist, &cause) != 0) { | 		if (cmd_string_parse(line, &cmdlist, &cause) != 0) { | ||||||
| 			control_write(c, "%%error in line \"%s\": %s", line, | 			control_write(c, "%%error in line \"%s\": %s", line, | ||||||
| 			    cause); | 			    cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 		} else { | 		} else { | ||||||
| 			cmd_list_exec(cmdlist, &ctx); | 			cmd_list_exec(cmdlist, &ctx); | ||||||
| 			cmd_list_free(cmdlist); | 			cmd_list_free(cmdlist); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		xfree(line); | 		free(line); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								environ.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								environ.c
									
									
									
									
									
								
							| @@ -51,10 +51,9 @@ environ_free(struct environ *env) | |||||||
| 	while (!RB_EMPTY(env)) { | 	while (!RB_EMPTY(env)) { | ||||||
| 		envent = RB_ROOT(env); | 		envent = RB_ROOT(env); | ||||||
| 		RB_REMOVE(environ, env, envent); | 		RB_REMOVE(environ, env, envent); | ||||||
| 		xfree(envent->name); | 		free(envent->name); | ||||||
| 		if (envent->value != NULL) | 		free(envent->value); | ||||||
| 			xfree(envent->value); | 		free(envent); | ||||||
| 		xfree(envent); |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -85,8 +84,7 @@ environ_set(struct environ *env, const char *name, const char *value) | |||||||
| 	struct environ_entry	*envent; | 	struct environ_entry	*envent; | ||||||
|  |  | ||||||
| 	if ((envent = environ_find(env, name)) != NULL) { | 	if ((envent = environ_find(env, name)) != NULL) { | ||||||
| 		if (envent->value != NULL) | 		free(envent->value); | ||||||
| 			xfree(envent->value); |  | ||||||
| 		if (value != NULL) | 		if (value != NULL) | ||||||
| 			envent->value = xstrdup(value); | 			envent->value = xstrdup(value); | ||||||
| 		else | 		else | ||||||
| @@ -117,7 +115,7 @@ environ_put(struct environ *env, const char *var) | |||||||
| 	name[strcspn(name, "=")] = '\0'; | 	name[strcspn(name, "=")] = '\0'; | ||||||
|  |  | ||||||
| 	environ_set(env, name, value); | 	environ_set(env, name, value); | ||||||
| 	xfree(name); | 	free(name); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Unset an environment variable. */ | /* Unset an environment variable. */ | ||||||
| @@ -129,10 +127,9 @@ environ_unset(struct environ *env, const char *name) | |||||||
| 	if ((envent = environ_find(env, name)) == NULL) | 	if ((envent = environ_find(env, name)) == NULL) | ||||||
| 		return; | 		return; | ||||||
| 	RB_REMOVE(environ, env, envent); | 	RB_REMOVE(environ, env, envent); | ||||||
| 	xfree(envent->name); | 	free(envent->name); | ||||||
| 	if (envent->value != NULL) | 	free(envent->value); | ||||||
| 		xfree(envent->value); | 	free(envent); | ||||||
| 	xfree(envent); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -152,7 +149,7 @@ environ_update(const char *vars, struct environ *srcenv, struct environ *dstenv) | |||||||
| 		else | 		else | ||||||
| 			environ_set(dstenv, envent->name, envent->value); | 			environ_set(dstenv, envent->name, envent->value); | ||||||
| 	} | 	} | ||||||
| 	xfree(copyvars); | 	free(copyvars); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Push environment into the real environment - use after fork(). */ | /* Push environment into the real environment - use after fork(). */ | ||||||
|   | |||||||
							
								
								
									
										19
									
								
								format.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								format.c
									
									
									
									
									
								
							| @@ -20,6 +20,7 @@ | |||||||
|  |  | ||||||
| #include <netdb.h> | #include <netdb.h> | ||||||
| #include <stdarg.h> | #include <stdarg.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| @@ -102,12 +103,12 @@ format_free(struct format_tree *ft) | |||||||
| 		fe_next = RB_NEXT(format_tree, ft, fe); | 		fe_next = RB_NEXT(format_tree, ft, fe); | ||||||
|  |  | ||||||
| 		RB_REMOVE(format_tree, ft, fe); | 		RB_REMOVE(format_tree, ft, fe); | ||||||
| 		xfree(fe->value); | 		free(fe->value); | ||||||
| 		xfree(fe->key); | 		free(fe->key); | ||||||
| 		xfree(fe); | 		free(fe); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree (ft); | 	free (ft); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Add a key-value pair. */ | /* Add a key-value pair. */ | ||||||
| @@ -195,11 +196,11 @@ format_replace(struct format_tree *ft, | |||||||
| 	memcpy(*buf + *off, value, valuelen); | 	memcpy(*buf + *off, value, valuelen); | ||||||
| 	*off += valuelen; | 	*off += valuelen; | ||||||
|  |  | ||||||
| 	xfree(copy); | 	free(copy); | ||||||
| 	return (0); | 	return (0); | ||||||
|  |  | ||||||
| fail: | fail: | ||||||
| 	xfree(copy); | 	free(copy); | ||||||
| 	return (-1); | 	return (-1); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -351,8 +352,8 @@ format_winlink(struct format_tree *ft, struct session *s, struct winlink *wl) | |||||||
| 	format_add(ft, "window_active", "%d", wl == s->curw); | 	format_add(ft, "window_active", "%d", wl == s->curw); | ||||||
| 	format_add(ft, "window_panes", "%u", window_count_panes(w)); | 	format_add(ft, "window_panes", "%u", window_count_panes(w)); | ||||||
|  |  | ||||||
| 	xfree(flags); | 	free(flags); | ||||||
| 	xfree(layout); | 	free(layout); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Set default format keys for a window pane. */ | /* Set default format keys for a window pane. */ | ||||||
| @@ -403,5 +404,5 @@ format_paste_buffer(struct format_tree *ft, struct paste_buffer *pb) | |||||||
| 	format_add(ft, "buffer_size", "%zu", pb->size); | 	format_add(ft, "buffer_size", "%zu", pb->size); | ||||||
| 	format_add(ft, "buffer_sample", "%s", pb_print); | 	format_add(ft, "buffer_sample", "%s", pb_print); | ||||||
|  |  | ||||||
| 	xfree(pb_print); | 	free(pb_print); | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										17
									
								
								grid.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								grid.c
									
									
									
									
									
								
							| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -98,15 +99,13 @@ grid_destroy(struct grid *gd) | |||||||
|  |  | ||||||
| 	for (yy = 0; yy < gd->hsize + gd->sy; yy++) { | 	for (yy = 0; yy < gd->hsize + gd->sy; yy++) { | ||||||
| 		gl = &gd->linedata[yy]; | 		gl = &gd->linedata[yy]; | ||||||
| 		if (gl->celldata != NULL) | 		free(gl->celldata); | ||||||
| 			xfree(gl->celldata); | 		free(gl->utf8data); | ||||||
| 		if (gl->utf8data != NULL) |  | ||||||
| 			xfree(gl->utf8data); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(gd->linedata); | 	free(gd->linedata); | ||||||
|  |  | ||||||
| 	xfree(gd); | 	free(gd); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Compare grids. */ | /* Compare grids. */ | ||||||
| @@ -373,10 +372,8 @@ grid_clear_lines(struct grid *gd, u_int py, u_int ny) | |||||||
|  |  | ||||||
| 	for (yy = py; yy < py + ny; yy++) { | 	for (yy = py; yy < py + ny; yy++) { | ||||||
| 		gl = &gd->linedata[yy]; | 		gl = &gd->linedata[yy]; | ||||||
| 		if (gl->celldata != NULL) | 		free(gl->celldata); | ||||||
| 			xfree(gl->celldata); | 		free(gl->utf8data); | ||||||
| 		if (gl->utf8data != NULL) |  | ||||||
| 			xfree(gl->utf8data); |  | ||||||
| 		memset(gl, 0, sizeof *gl); | 		memset(gl, 0, sizeof *gl); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -163,7 +163,7 @@ input_key(struct window_pane *wp, int key) | |||||||
| 	if (options_get_number(&wp->window->options, "xterm-keys")) { | 	if (options_get_number(&wp->window->options, "xterm-keys")) { | ||||||
| 		if ((out = xterm_keys_lookup(key)) != NULL) { | 		if ((out = xterm_keys_lookup(key)) != NULL) { | ||||||
| 			bufferevent_write(wp->event, out, strlen(out)); | 			bufferevent_write(wp->event, out, strlen(out)); | ||||||
| 			xfree(out); | 			free(out); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								input.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								input.c
									
									
									
									
									
								
							| @@ -853,7 +853,7 @@ input_reply(struct input_ctx *ictx, const char *fmt, ...) | |||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	bufferevent_write(ictx->wp->event, reply, strlen(reply)); | 	bufferevent_write(ictx->wp->event, reply, strlen(reply)); | ||||||
| 	xfree(reply); | 	free(reply); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Clear saved state. */ | /* Clear saved state. */ | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								job.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								job.c
									
									
									
									
									
								
							| @@ -20,6 +20,7 @@ | |||||||
| #include <sys/socket.h> | #include <sys/socket.h> | ||||||
|  |  | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  |  | ||||||
| @@ -116,7 +117,7 @@ job_free(struct job *job) | |||||||
| 	log_debug("free job %p: %s", job, job->cmd); | 	log_debug("free job %p: %s", job, job->cmd); | ||||||
|  |  | ||||||
| 	LIST_REMOVE(job, lentry); | 	LIST_REMOVE(job, lentry); | ||||||
| 	xfree(job->cmd); | 	free(job->cmd); | ||||||
|  |  | ||||||
| 	if (job->freefn != NULL && job->data != NULL) | 	if (job->freefn != NULL && job->data != NULL) | ||||||
| 		job->freefn(job->data); | 		job->freefn(job->data); | ||||||
| @@ -128,7 +129,7 @@ job_free(struct job *job) | |||||||
| 	if (job->fd != -1) | 	if (job->fd != -1) | ||||||
| 		close(job->fd); | 		close(job->fd); | ||||||
|  |  | ||||||
| 	xfree(job); | 	free(job); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Job buffer error callback. */ | /* Job buffer error callback. */ | ||||||
|   | |||||||
| @@ -90,7 +90,7 @@ key_bindings_clean(void) | |||||||
| 		bd = RB_ROOT(&dead_key_bindings); | 		bd = RB_ROOT(&dead_key_bindings); | ||||||
| 		RB_REMOVE(key_bindings, &dead_key_bindings, bd); | 		RB_REMOVE(key_bindings, &dead_key_bindings, bd); | ||||||
| 		cmd_list_free(bd->cmdlist); | 		cmd_list_free(bd->cmdlist); | ||||||
| 		xfree(bd); | 		free(bd); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -216,7 +216,7 @@ key_bindings_error(struct cmd_ctx *ctx, const char *fmt, ...) | |||||||
|  |  | ||||||
| 	*msg = toupper((u_char) *msg); | 	*msg = toupper((u_char) *msg); | ||||||
| 	status_message_set(ctx->curclient, "%s", msg); | 	status_message_set(ctx->curclient, "%s", msg); | ||||||
| 	xfree(msg); | 	free(msg); | ||||||
| } | } | ||||||
|  |  | ||||||
| void printflike2 | void printflike2 | ||||||
| @@ -258,7 +258,7 @@ key_bindings_info(struct cmd_ctx *ctx, const char *fmt, ...) | |||||||
|  |  | ||||||
| 	*msg = toupper((u_char) *msg); | 	*msg = toupper((u_char) *msg); | ||||||
| 	status_message_set(ctx->curclient, "%s", msg); | 	status_message_set(ctx->curclient, "%s", msg); | ||||||
| 	xfree(msg); | 	free(msg); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								layout.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								layout.c
									
									
									
									
									
								
							| @@ -78,7 +78,7 @@ layout_free_cell(struct layout_cell *lc) | |||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(lc); | 	free(lc); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
| @@ -781,8 +781,8 @@ layout_list_add(struct window *w) | |||||||
| 		TAILQ_REMOVE(&w->layout_list, ll, entry); | 		TAILQ_REMOVE(&w->layout_list, ll, entry); | ||||||
| 		w->layout_list_size--; | 		w->layout_list_size--; | ||||||
|  |  | ||||||
| 		xfree(ll->layout); | 		free(ll->layout); | ||||||
| 		xfree(ll); | 		free(ll); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										9
									
								
								names.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								names.c
									
									
									
									
									
								
							| @@ -20,6 +20,7 @@ | |||||||
|  |  | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <libgen.h> | #include <libgen.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  |  | ||||||
| @@ -73,12 +74,12 @@ window_name_callback(unused int fd, unused short events, void *data) | |||||||
| 			wname = parse_window_name(name + 1); | 			wname = parse_window_name(name + 1); | ||||||
| 		else | 		else | ||||||
| 				wname = parse_window_name(name); | 				wname = parse_window_name(name); | ||||||
| 		xfree(name); | 		free(name); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (w->active->fd == -1) { | 	if (w->active->fd == -1) { | ||||||
| 		xasprintf(&name, "%s[dead]", wname); | 		xasprintf(&name, "%s[dead]", wname); | ||||||
| 		xfree(wname); | 		free(wname); | ||||||
| 		wname = name; | 		wname = name; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -86,7 +87,7 @@ window_name_callback(unused int fd, unused short events, void *data) | |||||||
| 		window_set_name(w, wname); | 		window_set_name(w, wname); | ||||||
| 		server_status_window(w); | 		server_status_window(w); | ||||||
| 	} | 	} | ||||||
| 	xfree(wname); | 	free(wname); | ||||||
| } | } | ||||||
|  |  | ||||||
| char * | char * | ||||||
| @@ -122,6 +123,6 @@ parse_window_name(const char *in) | |||||||
| 	if (*name == '/') | 	if (*name == '/') | ||||||
| 		name = basename(name); | 		name = basename(name); | ||||||
| 	name = xstrdup(name); | 	name = xstrdup(name); | ||||||
| 	xfree(copy); | 	free(copy); | ||||||
| 	return (name); | 	return (name); | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										17
									
								
								options.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								options.c
									
									
									
									
									
								
							| @@ -19,6 +19,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
| #include <stdarg.h> | #include <stdarg.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -51,10 +52,10 @@ options_free(struct options *oo) | |||||||
| 	while (!RB_EMPTY(&oo->tree)) { | 	while (!RB_EMPTY(&oo->tree)) { | ||||||
| 		o = RB_ROOT(&oo->tree); | 		o = RB_ROOT(&oo->tree); | ||||||
| 		RB_REMOVE(options_tree, &oo->tree, o); | 		RB_REMOVE(options_tree, &oo->tree, o); | ||||||
| 		xfree(o->name); | 		free(o->name); | ||||||
| 		if (o->type == OPTIONS_STRING) | 		if (o->type == OPTIONS_STRING) | ||||||
| 			xfree(o->str); | 			free(o->str); | ||||||
| 		xfree(o); | 		free(o); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -92,10 +93,10 @@ options_remove(struct options *oo, const char *name) | |||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	RB_REMOVE(options_tree, &oo->tree, o); | 	RB_REMOVE(options_tree, &oo->tree, o); | ||||||
| 	xfree(o->name); | 	free(o->name); | ||||||
| 	if (o->type == OPTIONS_STRING) | 	if (o->type == OPTIONS_STRING) | ||||||
| 		xfree(o->str); | 		free(o->str); | ||||||
| 	xfree(o); | 	free(o); | ||||||
| } | } | ||||||
|  |  | ||||||
| struct options_entry *printflike3 | struct options_entry *printflike3 | ||||||
| @@ -109,7 +110,7 @@ options_set_string(struct options *oo, const char *name, const char *fmt, ...) | |||||||
| 		o->name = xstrdup(name); | 		o->name = xstrdup(name); | ||||||
| 		RB_INSERT(options_tree, &oo->tree, o); | 		RB_INSERT(options_tree, &oo->tree, o); | ||||||
| 	} else if (o->type == OPTIONS_STRING) | 	} else if (o->type == OPTIONS_STRING) | ||||||
| 		xfree(o->str); | 		free(o->str); | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	o->type = OPTIONS_STRING; | 	o->type = OPTIONS_STRING; | ||||||
| @@ -140,7 +141,7 @@ options_set_number(struct options *oo, const char *name, long long value) | |||||||
| 		o->name = xstrdup(name); | 		o->name = xstrdup(name); | ||||||
| 		RB_INSERT(options_tree, &oo->tree, o); | 		RB_INSERT(options_tree, &oo->tree, o); | ||||||
| 	} else if (o->type == OPTIONS_STRING) | 	} else if (o->type == OPTIONS_STRING) | ||||||
| 		xfree(o->str); | 		free(o->str); | ||||||
|  |  | ||||||
| 	o->type = OPTIONS_NUMBER; | 	o->type = OPTIONS_NUMBER; | ||||||
| 	o->num = value; | 	o->num = value; | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								paste.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								paste.c
									
									
									
									
									
								
							| @@ -19,6 +19,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
| #include <sys/time.h> | #include <sys/time.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -69,8 +70,8 @@ paste_free_top(struct paste_stack *ps) | |||||||
| 	pb = ARRAY_FIRST(ps); | 	pb = ARRAY_FIRST(ps); | ||||||
| 	ARRAY_REMOVE(ps, 0); | 	ARRAY_REMOVE(ps, 0); | ||||||
|  |  | ||||||
| 	xfree(pb->data); | 	free(pb->data); | ||||||
| 	xfree(pb); | 	free(pb); | ||||||
|  |  | ||||||
| 	return (0); | 	return (0); | ||||||
| } | } | ||||||
| @@ -87,8 +88,8 @@ paste_free_index(struct paste_stack *ps, u_int idx) | |||||||
| 	pb = ARRAY_ITEM(ps, idx); | 	pb = ARRAY_ITEM(ps, idx); | ||||||
| 	ARRAY_REMOVE(ps, idx); | 	ARRAY_REMOVE(ps, idx); | ||||||
|  |  | ||||||
| 	xfree(pb->data); | 	free(pb->data); | ||||||
| 	xfree(pb); | 	free(pb); | ||||||
|  |  | ||||||
| 	return (0); | 	return (0); | ||||||
| } | } | ||||||
| @@ -107,8 +108,8 @@ paste_add(struct paste_stack *ps, char *data, size_t size, u_int limit) | |||||||
|  |  | ||||||
| 	while (ARRAY_LENGTH(ps) >= limit) { | 	while (ARRAY_LENGTH(ps) >= limit) { | ||||||
| 		pb = ARRAY_LAST(ps); | 		pb = ARRAY_LAST(ps); | ||||||
| 		xfree(pb->data); | 		free(pb->data); | ||||||
| 		xfree(pb); | 		free(pb); | ||||||
| 		ARRAY_TRUNC(ps, 1); | 		ARRAY_TRUNC(ps, 1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -136,7 +137,7 @@ paste_replace(struct paste_stack *ps, u_int idx, char *data, size_t size) | |||||||
| 		return (-1); | 		return (-1); | ||||||
|  |  | ||||||
| 	pb = ARRAY_ITEM(ps, idx); | 	pb = ARRAY_ITEM(ps, idx); | ||||||
| 	xfree(pb->data); | 	free(pb->data); | ||||||
|  |  | ||||||
| 	pb->data = data; | 	pb->data = data; | ||||||
| 	pb->size = size; | 	pb->size = size; | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -102,8 +103,8 @@ screen_write_cstrlen(int utf8flag, const char *fmt, ...) | |||||||
|  |  | ||||||
| 	size = screen_write_strlen(utf8flag, "%s", msg2); | 	size = screen_write_strlen(utf8flag, "%s", msg2); | ||||||
|  |  | ||||||
| 	xfree(msg); | 	free(msg); | ||||||
| 	xfree(msg2); | 	free(msg2); | ||||||
|  |  | ||||||
| 	return (size); | 	return (size); | ||||||
| } | } | ||||||
| @@ -141,7 +142,7 @@ screen_write_strlen(int utf8flag, const char *fmt, ...) | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(msg); | 	free(msg); | ||||||
| 	return (size); | 	return (size); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -215,7 +216,7 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen, | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(msg); | 	free(msg); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Write string, similar to nputs, but with embedded formatting (#[]). */ | /* Write string, similar to nputs, but with embedded formatting (#[]). */ | ||||||
| @@ -285,7 +286,7 @@ screen_write_cnputs(struct screen_write_ctx *ctx, | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(msg); | 	free(msg); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Parse an embedded style of the form "fg=colour,bg=colour,bright,...". */ | /* Parse an embedded style of the form "fg=colour,bg=colour,bright,...". */ | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								screen.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								screen.c
									
									
									
									
									
								
							| @@ -71,10 +71,9 @@ screen_reinit(struct screen *s) | |||||||
| void | void | ||||||
| screen_free(struct screen *s) | screen_free(struct screen *s) | ||||||
| { | { | ||||||
| 	if (s->tabs != NULL) | 	free(s->tabs); | ||||||
| 		xfree(s->tabs); | 	free(s->title); | ||||||
| 	xfree(s->title); | 	free(s->ccolour); | ||||||
| 	xfree(s->ccolour); |  | ||||||
| 	grid_destroy(s->grid); | 	grid_destroy(s->grid); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -84,8 +83,7 @@ screen_reset_tabs(struct screen *s) | |||||||
| { | { | ||||||
| 	u_int	i; | 	u_int	i; | ||||||
|  |  | ||||||
| 	if (s->tabs != NULL) | 	free(s->tabs); | ||||||
| 		xfree(s->tabs); |  | ||||||
|  |  | ||||||
| 	if ((s->tabs = bit_alloc(screen_size_x(s))) == NULL) | 	if ((s->tabs = bit_alloc(screen_size_x(s))) == NULL) | ||||||
| 		fatal("bit_alloc failed"); | 		fatal("bit_alloc failed"); | ||||||
| @@ -105,7 +103,7 @@ screen_set_cursor_style(struct screen *s, u_int style) | |||||||
| void | void | ||||||
| screen_set_cursor_colour(struct screen *s, const char *colour_string) | screen_set_cursor_colour(struct screen *s, const char *colour_string) | ||||||
| { | { | ||||||
| 	xfree(s->ccolour); | 	free(s->ccolour); | ||||||
| 	s->ccolour = xstrdup(colour_string); | 	s->ccolour = xstrdup(colour_string); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -117,7 +115,7 @@ screen_set_title(struct screen *s, const char *title) | |||||||
|  |  | ||||||
| 	strlcpy(tmp, title, sizeof tmp); | 	strlcpy(tmp, title, sizeof tmp); | ||||||
|  |  | ||||||
| 	xfree(s->title); | 	free(s->title); | ||||||
| 	s->title = xstrdup(tmp); | 	s->title = xstrdup(tmp); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ | |||||||
|  |  | ||||||
| #include <event.h> | #include <event.h> | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| @@ -150,31 +151,25 @@ server_client_lost(struct client *c) | |||||||
| 	status_free_jobs(&c->status_old); | 	status_free_jobs(&c->status_old); | ||||||
| 	screen_free(&c->status); | 	screen_free(&c->status); | ||||||
|  |  | ||||||
| 	if (c->title != NULL) | 	free(c->title); | ||||||
| 		xfree(c->title); |  | ||||||
|  |  | ||||||
| 	evtimer_del(&c->repeat_timer); | 	evtimer_del(&c->repeat_timer); | ||||||
|  |  | ||||||
| 	if (event_initialized(&c->identify_timer)) | 	if (event_initialized(&c->identify_timer)) | ||||||
| 		evtimer_del(&c->identify_timer); | 		evtimer_del(&c->identify_timer); | ||||||
|  |  | ||||||
| 	if (c->message_string != NULL) | 	free(c->message_string); | ||||||
| 		xfree(c->message_string); |  | ||||||
| 	if (event_initialized (&c->message_timer)) | 	if (event_initialized (&c->message_timer)) | ||||||
| 		evtimer_del(&c->message_timer); | 		evtimer_del(&c->message_timer); | ||||||
| 	for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) { | 	for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) { | ||||||
| 		msg = &ARRAY_ITEM(&c->message_log, i); | 		msg = &ARRAY_ITEM(&c->message_log, i); | ||||||
| 		xfree(msg->msg); | 		free(msg->msg); | ||||||
| 	} | 	} | ||||||
| 	ARRAY_FREE(&c->message_log); | 	ARRAY_FREE(&c->message_log); | ||||||
|  |  | ||||||
| 	if (c->prompt_string != NULL) | 	free(c->prompt_string); | ||||||
| 		xfree(c->prompt_string); | 	free(c->prompt_buffer); | ||||||
| 	if (c->prompt_buffer != NULL) | 	free(c->cwd); | ||||||
| 		xfree(c->prompt_buffer); |  | ||||||
|  |  | ||||||
| 	if (c->cwd != NULL) |  | ||||||
| 		xfree(c->cwd); |  | ||||||
|  |  | ||||||
| 	environ_free(&c->environ); | 	environ_free(&c->environ); | ||||||
|  |  | ||||||
| @@ -661,12 +656,11 @@ server_client_set_title(struct client *c) | |||||||
|  |  | ||||||
| 	title = status_replace(c, NULL, NULL, NULL, template, time(NULL), 1); | 	title = status_replace(c, NULL, NULL, NULL, template, time(NULL), 1); | ||||||
| 	if (c->title == NULL || strcmp(title, c->title) != 0) { | 	if (c->title == NULL || strcmp(title, c->title) != 0) { | ||||||
| 		if (c->title != NULL) | 		free(c->title); | ||||||
| 			xfree(c->title); |  | ||||||
| 		c->title = xstrdup(title); | 		c->title = xstrdup(title); | ||||||
| 		tty_set_title(&c->tty, c->title); | 		tty_set_title(&c->tty, c->title); | ||||||
| 	} | 	} | ||||||
| 	xfree(title); | 	free(title); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Dispatch message from client. */ | /* Dispatch message from client. */ | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| @@ -393,7 +394,7 @@ server_destroy_session_group(struct session *s) | |||||||
| 		TAILQ_FOREACH(s, &sg->sessions, gentry) | 		TAILQ_FOREACH(s, &sg->sessions, gentry) | ||||||
| 			server_destroy_session(s); | 			server_destroy_session(s); | ||||||
| 		TAILQ_REMOVE(&session_groups, sg, entry); | 		TAILQ_REMOVE(&session_groups, sg, entry); | ||||||
| 		xfree(sg); | 		free(sg); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
| #include <event.h> | #include <event.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -211,7 +212,7 @@ server_window_check_content( | |||||||
| 		return (0); | 		return (0); | ||||||
| 	if ((found = window_pane_search(wp, ptr, NULL)) == NULL) | 	if ((found = window_pane_search(wp, ptr, NULL)) == NULL) | ||||||
| 		return (0); | 		return (0); | ||||||
| 	xfree(found); | 	free(found); | ||||||
|  |  | ||||||
| 	if (options_get_number(&s->options, "bell-on-alert")) | 	if (options_get_number(&s->options, "bell-on-alert")) | ||||||
| 		ring_bell(s); | 		ring_bell(s); | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								server.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								server.c
									
									
									
									
									
								
							| @@ -163,7 +163,7 @@ server_start(int lockfd, char *lockfile) | |||||||
| 	server_client_create(pair[1]); | 	server_client_create(pair[1]); | ||||||
|  |  | ||||||
| 	unlink(lockfile); | 	unlink(lockfile); | ||||||
| 	xfree(lockfile); | 	free(lockfile); | ||||||
| 	close(lockfd); | 	close(lockfd); | ||||||
|  |  | ||||||
| 	if (access(SYSTEM_CFG, R_OK) == 0) | 	if (access(SYSTEM_CFG, R_OK) == 0) | ||||||
| @@ -186,7 +186,7 @@ server_start(int lockfd, char *lockfile) | |||||||
| 		for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) { | 		for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) { | ||||||
| 			cause = ARRAY_ITEM(&cfg_causes, i); | 			cause = ARRAY_ITEM(&cfg_causes, i); | ||||||
| 			window_copy_add(wp, "%s", cause); | 			window_copy_add(wp, "%s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 		} | 		} | ||||||
| 		ARRAY_FREE(&cfg_causes); | 		ARRAY_FREE(&cfg_causes); | ||||||
| 	} | 	} | ||||||
| @@ -276,8 +276,8 @@ server_clean_dead(void) | |||||||
| 		next_s = RB_NEXT(sessions, &dead_sessions, s); | 		next_s = RB_NEXT(sessions, &dead_sessions, s); | ||||||
| 		if (s->references == 0) { | 		if (s->references == 0) { | ||||||
| 			RB_REMOVE(sessions, &dead_sessions, s); | 			RB_REMOVE(sessions, &dead_sessions, s); | ||||||
| 			xfree(s->name); | 			free(s->name); | ||||||
| 			xfree(s); | 			free(s); | ||||||
| 		} | 		} | ||||||
| 		s = next_s; | 		s = next_s; | ||||||
| 	} | 	} | ||||||
| @@ -287,7 +287,7 @@ server_clean_dead(void) | |||||||
| 		if (c == NULL || c->references != 0) | 		if (c == NULL || c->references != 0) | ||||||
| 			continue; | 			continue; | ||||||
| 		ARRAY_SET(&dead_clients, i, NULL); | 		ARRAY_SET(&dead_clients, i, NULL); | ||||||
| 		xfree(c); | 		free(c); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								session.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								session.c
									
									
									
									
									
								
							| @@ -125,8 +125,7 @@ session_create(const char *name, const char *cmd, const char *cwd, | |||||||
| 		s->name = NULL; | 		s->name = NULL; | ||||||
| 		do { | 		do { | ||||||
| 			s->idx = next_session++; | 			s->idx = next_session++; | ||||||
| 			if (s->name != NULL) | 			free (s->name); | ||||||
| 				xfree (s->name); |  | ||||||
| 			xasprintf(&s->name, "%u", s->idx); | 			xasprintf(&s->name, "%u", s->idx); | ||||||
| 		} while (RB_FIND(sessions, &sessions, s) != NULL); | 		} while (RB_FIND(sessions, &sessions, s) != NULL); | ||||||
| 	} | 	} | ||||||
| @@ -156,8 +155,7 @@ session_destroy(struct session *s) | |||||||
| 	RB_REMOVE(sessions, &sessions, s); | 	RB_REMOVE(sessions, &sessions, s); | ||||||
| 	notify_session_closed(s); | 	notify_session_closed(s); | ||||||
|  |  | ||||||
| 	if (s->tio != NULL) | 	free(s->tio); | ||||||
| 		xfree(s->tio); |  | ||||||
|  |  | ||||||
| 	session_group_remove(s); | 	session_group_remove(s); | ||||||
| 	environ_free(&s->environ); | 	environ_free(&s->environ); | ||||||
| @@ -171,7 +169,7 @@ session_destroy(struct session *s) | |||||||
| 		winlink_remove(&s->windows, wl); | 		winlink_remove(&s->windows, wl); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(s->cwd); | 	free(s->cwd); | ||||||
|  |  | ||||||
| 	RB_INSERT(sessions, &dead_sessions, s); | 	RB_INSERT(sessions, &dead_sessions, s); | ||||||
| } | } | ||||||
| @@ -494,7 +492,7 @@ session_group_remove(struct session *s) | |||||||
| 		TAILQ_REMOVE(&sg->sessions, TAILQ_FIRST(&sg->sessions), gentry); | 		TAILQ_REMOVE(&sg->sessions, TAILQ_FIRST(&sg->sessions), gentry); | ||||||
| 	if (TAILQ_EMPTY(&sg->sessions)) { | 	if (TAILQ_EMPTY(&sg->sessions)) { | ||||||
| 		TAILQ_REMOVE(&session_groups, sg, entry); | 		TAILQ_REMOVE(&session_groups, sg, entry); | ||||||
| 		xfree(sg); | 		free(sg); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										45
									
								
								status.c
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								status.c
									
									
									
									
									
								
							| @@ -222,8 +222,7 @@ status_redraw(struct client *c) | |||||||
| 	/* Calculate the total size needed for the window list. */ | 	/* Calculate the total size needed for the window list. */ | ||||||
| 	wlstart = wloffset = wlwidth = 0; | 	wlstart = wloffset = wlwidth = 0; | ||||||
| 	RB_FOREACH(wl, winlinks, &s->windows) { | 	RB_FOREACH(wl, winlinks, &s->windows) { | ||||||
| 		if (wl->status_text != NULL) | 		free(wl->status_text); | ||||||
| 			xfree(wl->status_text); |  | ||||||
| 		memcpy(&wl->status_cell, &stdgc, sizeof wl->status_cell); | 		memcpy(&wl->status_cell, &stdgc, sizeof wl->status_cell); | ||||||
| 		wl->status_text = status_print(c, wl, t, &wl->status_cell); | 		wl->status_text = status_print(c, wl, t, &wl->status_cell); | ||||||
| 		wl->status_width = | 		wl->status_width = | ||||||
| @@ -372,10 +371,8 @@ draw: | |||||||
| 	screen_write_stop(&ctx); | 	screen_write_stop(&ctx); | ||||||
|  |  | ||||||
| out: | out: | ||||||
| 	if (left != NULL) | 	free(left); | ||||||
| 		xfree(left); | 	free(right); | ||||||
| 	if (right != NULL) |  | ||||||
| 		xfree(right); |  | ||||||
|  |  | ||||||
| 	if (grid_compare(c->status.grid, old_status.grid) == 0) { | 	if (grid_compare(c->status.grid, old_status.grid) == 0) { | ||||||
| 		screen_free(&old_status); | 		screen_free(&old_status); | ||||||
| @@ -491,8 +488,7 @@ do_replace: | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| out: | out: | ||||||
| 	if (freeptr != NULL) | 	free(freeptr); | ||||||
| 		xfree(freeptr); |  | ||||||
| 	return; | 	return; | ||||||
|  |  | ||||||
| skip_to: | skip_to: | ||||||
| @@ -572,7 +568,7 @@ status_find_job(struct client *c, char **iptr) | |||||||
| 		cmd[len++] = **iptr; | 		cmd[len++] = **iptr; | ||||||
| 	} | 	} | ||||||
| 	if (**iptr == '\0')		/* no terminating ) */ { | 	if (**iptr == '\0')		/* no terminating ) */ { | ||||||
| 		xfree(cmd); | 		free(cmd); | ||||||
| 		return (NULL); | 		return (NULL); | ||||||
| 	} | 	} | ||||||
| 	(*iptr)++;			/* skip final ) */ | 	(*iptr)++;			/* skip final ) */ | ||||||
| @@ -582,7 +578,7 @@ status_find_job(struct client *c, char **iptr) | |||||||
| 	so_find.cmd = cmd; | 	so_find.cmd = cmd; | ||||||
| 	so = RB_FIND(status_out_tree, &c->status_new, &so_find); | 	so = RB_FIND(status_out_tree, &c->status_new, &so_find); | ||||||
| 	if (so != NULL && so->out != NULL) { | 	if (so != NULL && so->out != NULL) { | ||||||
| 		xfree(cmd); | 		free(cmd); | ||||||
| 		return (so->out); | 		return (so->out); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -600,7 +596,7 @@ status_find_job(struct client *c, char **iptr) | |||||||
| 	/* Lookup in the old tree. */ | 	/* Lookup in the old tree. */ | ||||||
| 	so_find.cmd = cmd; | 	so_find.cmd = cmd; | ||||||
| 	so = RB_FIND(status_out_tree, &c->status_old, &so_find); | 	so = RB_FIND(status_out_tree, &c->status_old, &so_find); | ||||||
| 	xfree(cmd); | 	free(cmd); | ||||||
| 	if (so != NULL) | 	if (so != NULL) | ||||||
| 		return (so->out); | 		return (so->out); | ||||||
| 	return (NULL); | 	return (NULL); | ||||||
| @@ -618,10 +614,9 @@ status_free_jobs(struct status_out_tree *sotree) | |||||||
| 		so_next = RB_NEXT(status_out_tree, sotree, so); | 		so_next = RB_NEXT(status_out_tree, sotree, so); | ||||||
|  |  | ||||||
| 		RB_REMOVE(status_out_tree, sotree, so); | 		RB_REMOVE(status_out_tree, sotree, so); | ||||||
| 		if (so->out != NULL) | 		free(so->out); | ||||||
| 			xfree(so->out); | 		free(so->cmd); | ||||||
| 		xfree(so->cmd); | 		free(so); | ||||||
| 		xfree(so); |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -778,7 +773,7 @@ status_message_set(struct client *c, const char *fmt, ...) | |||||||
| 		limit = ARRAY_LENGTH(&c->message_log) - limit; | 		limit = ARRAY_LENGTH(&c->message_log) - limit; | ||||||
| 		for (i = 0; i < limit; i++) { | 		for (i = 0; i < limit; i++) { | ||||||
| 			msg = &ARRAY_FIRST(&c->message_log); | 			msg = &ARRAY_FIRST(&c->message_log); | ||||||
| 			xfree(msg->msg); | 			free(msg->msg); | ||||||
| 			ARRAY_REMOVE(&c->message_log, 0); | 			ARRAY_REMOVE(&c->message_log, 0); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -803,7 +798,7 @@ status_message_clear(struct client *c) | |||||||
| 	if (c->message_string == NULL) | 	if (c->message_string == NULL) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	xfree(c->message_string); | 	free(c->message_string); | ||||||
| 	c->message_string = NULL; | 	c->message_string = NULL; | ||||||
|  |  | ||||||
| 	c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); | 	c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); | ||||||
| @@ -912,10 +907,10 @@ status_prompt_clear(struct client *c) | |||||||
| 	if (c->prompt_freefn != NULL && c->prompt_data != NULL) | 	if (c->prompt_freefn != NULL && c->prompt_data != NULL) | ||||||
| 		c->prompt_freefn(c->prompt_data); | 		c->prompt_freefn(c->prompt_data); | ||||||
|  |  | ||||||
| 	xfree(c->prompt_string); | 	free(c->prompt_string); | ||||||
| 	c->prompt_string = NULL; | 	c->prompt_string = NULL; | ||||||
|  |  | ||||||
| 	xfree(c->prompt_buffer); | 	free(c->prompt_buffer); | ||||||
| 	c->prompt_buffer = NULL; | 	c->prompt_buffer = NULL; | ||||||
|  |  | ||||||
| 	c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); | 	c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); | ||||||
| @@ -928,11 +923,11 @@ status_prompt_clear(struct client *c) | |||||||
| void | void | ||||||
| status_prompt_update(struct client *c, const char *msg, const char *input) | status_prompt_update(struct client *c, const char *msg, const char *input) | ||||||
| { | { | ||||||
| 	xfree(c->prompt_string); | 	free(c->prompt_string); | ||||||
| 	c->prompt_string = status_replace(c, NULL, NULL, NULL, msg, | 	c->prompt_string = status_replace(c, NULL, NULL, NULL, msg, | ||||||
| 	    time(NULL), 0); | 	    time(NULL), 0); | ||||||
|  |  | ||||||
| 	xfree(c->prompt_buffer); | 	free(c->prompt_buffer); | ||||||
| 	c->prompt_buffer = status_replace(c, NULL, NULL, NULL, input, | 	c->prompt_buffer = status_replace(c, NULL, NULL, NULL, input, | ||||||
| 	    time(NULL), 0); | 	    time(NULL), 0); | ||||||
| 	c->prompt_index = strlen(c->prompt_buffer); | 	c->prompt_index = strlen(c->prompt_buffer); | ||||||
| @@ -1109,7 +1104,7 @@ status_prompt_key(struct client *c, int key) | |||||||
| 		memcpy(first, s, strlen(s)); | 		memcpy(first, s, strlen(s)); | ||||||
|  |  | ||||||
| 		c->prompt_index = (first - c->prompt_buffer) + strlen(s); | 		c->prompt_index = (first - c->prompt_buffer) + strlen(s); | ||||||
| 		xfree(s); | 		free(s); | ||||||
|  |  | ||||||
| 		c->flags |= CLIENT_STATUS; | 		c->flags |= CLIENT_STATUS; | ||||||
| 		break; | 		break; | ||||||
| @@ -1250,7 +1245,7 @@ status_prompt_key(struct client *c, int key) | |||||||
| 		histstr = status_prompt_up_history(&c->prompt_hindex); | 		histstr = status_prompt_up_history(&c->prompt_hindex); | ||||||
| 		if (histstr == NULL) | 		if (histstr == NULL) | ||||||
| 			break; | 			break; | ||||||
| 		xfree(c->prompt_buffer); | 		free(c->prompt_buffer); | ||||||
| 		c->prompt_buffer = xstrdup(histstr); | 		c->prompt_buffer = xstrdup(histstr); | ||||||
| 		c->prompt_index = strlen(c->prompt_buffer); | 		c->prompt_index = strlen(c->prompt_buffer); | ||||||
| 		c->flags |= CLIENT_STATUS; | 		c->flags |= CLIENT_STATUS; | ||||||
| @@ -1259,7 +1254,7 @@ status_prompt_key(struct client *c, int key) | |||||||
| 		histstr = status_prompt_down_history(&c->prompt_hindex); | 		histstr = status_prompt_down_history(&c->prompt_hindex); | ||||||
| 		if (histstr == NULL) | 		if (histstr == NULL) | ||||||
| 			break; | 			break; | ||||||
| 		xfree(c->prompt_buffer); | 		free(c->prompt_buffer); | ||||||
| 		c->prompt_buffer = xstrdup(histstr); | 		c->prompt_buffer = xstrdup(histstr); | ||||||
| 		c->prompt_index = strlen(c->prompt_buffer); | 		c->prompt_index = strlen(c->prompt_buffer); | ||||||
| 		c->flags |= CLIENT_STATUS; | 		c->flags |= CLIENT_STATUS; | ||||||
| @@ -1383,7 +1378,7 @@ status_prompt_add_history(const char *line) | |||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	if (size == PROMPT_HISTORY) { | 	if (size == PROMPT_HISTORY) { | ||||||
| 		xfree(ARRAY_FIRST(&status_prompt_history)); | 		free(ARRAY_FIRST(&status_prompt_history)); | ||||||
| 		ARRAY_REMOVE(&status_prompt_history, 0); | 		ARRAY_REMOVE(&status_prompt_history, 0); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								tmux.c
									
									
									
									
									
								
							| @@ -76,7 +76,7 @@ logfile(const char *name) | |||||||
| 	if (debug_level > 0) { | 	if (debug_level > 0) { | ||||||
| 		xasprintf(&path, "tmux-%s-%ld.log", name, (long) getpid()); | 		xasprintf(&path, "tmux-%s-%ld.log", name, (long) getpid()); | ||||||
| 		log_open(debug_level, path); | 		log_open(debug_level, path); | ||||||
| 		xfree(path); | 		free(path); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -255,8 +255,7 @@ main(int argc, char **argv) | |||||||
| 			flags &= ~IDENTIFY_256COLOURS; | 			flags &= ~IDENTIFY_256COLOURS; | ||||||
| 			break; | 			break; | ||||||
| 		case 'c': | 		case 'c': | ||||||
| 			if (shell_cmd != NULL) | 			free(shell_cmd); | ||||||
| 				xfree(shell_cmd); |  | ||||||
| 			shell_cmd = xstrdup(optarg); | 			shell_cmd = xstrdup(optarg); | ||||||
| 			break; | 			break; | ||||||
| 		case 'C': | 		case 'C': | ||||||
| @@ -269,24 +268,21 @@ main(int argc, char **argv) | |||||||
| 			printf("%s %s\n", __progname, VERSION); | 			printf("%s %s\n", __progname, VERSION); | ||||||
| 			exit(0); | 			exit(0); | ||||||
| 		case 'f': | 		case 'f': | ||||||
| 			if (cfg_file != NULL) | 			free(cfg_file); | ||||||
| 				xfree(cfg_file); |  | ||||||
| 			cfg_file = xstrdup(optarg); | 			cfg_file = xstrdup(optarg); | ||||||
| 			break; | 			break; | ||||||
| 		case 'l': | 		case 'l': | ||||||
| 			login_shell = 1; | 			login_shell = 1; | ||||||
| 			break; | 			break; | ||||||
| 		case 'L': | 		case 'L': | ||||||
| 			if (label != NULL) | 			free(label); | ||||||
| 				xfree(label); |  | ||||||
| 			label = xstrdup(optarg); | 			label = xstrdup(optarg); | ||||||
| 			break; | 			break; | ||||||
| 		case 'q': | 		case 'q': | ||||||
| 			quiet = 1; | 			quiet = 1; | ||||||
| 			break; | 			break; | ||||||
| 		case 'S': | 		case 'S': | ||||||
| 			if (path != NULL) | 			free(path); | ||||||
| 				xfree(path); |  | ||||||
| 			path = xstrdup(optarg); | 			path = xstrdup(optarg); | ||||||
| 			break; | 			break; | ||||||
| 		case 'u': | 		case 'u': | ||||||
| @@ -366,7 +362,7 @@ main(int argc, char **argv) | |||||||
| 		} | 		} | ||||||
| 		xasprintf(&cfg_file, "%s/%s", home, DEFAULT_CFG); | 		xasprintf(&cfg_file, "%s/%s", home, DEFAULT_CFG); | ||||||
| 		if (access(cfg_file, R_OK) != 0 && errno == ENOENT) { | 		if (access(cfg_file, R_OK) != 0 && errno == ENOENT) { | ||||||
| 			xfree(cfg_file); | 			free(cfg_file); | ||||||
| 			cfg_file = NULL; | 			cfg_file = NULL; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -393,11 +389,10 @@ main(int argc, char **argv) | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	if (label != NULL) | 	free(label); | ||||||
| 		xfree(label); |  | ||||||
| 	if (realpath(path, socket_path) == NULL) | 	if (realpath(path, socket_path) == NULL) | ||||||
| 		strlcpy(socket_path, path, sizeof socket_path); | 		strlcpy(socket_path, path, sizeof socket_path); | ||||||
| 	xfree(path); | 	free(path); | ||||||
|  |  | ||||||
| #ifdef HAVE_SETPROCTITLE | #ifdef HAVE_SETPROCTITLE | ||||||
| 	/* Set process title. */ | 	/* Set process title. */ | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								tmux.h
									
									
									
									
									
								
							| @@ -2221,7 +2221,6 @@ char		*xstrdup(const char *); | |||||||
| void		*xcalloc(size_t, size_t); | void		*xcalloc(size_t, size_t); | ||||||
| void		*xmalloc(size_t); | void		*xmalloc(size_t); | ||||||
| void		*xrealloc(void *, size_t, size_t); | void		*xrealloc(void *, size_t, size_t); | ||||||
| void		 xfree(void *); |  | ||||||
| int printflike2	 xasprintf(char **, const char *, ...); | int printflike2	 xasprintf(char **, const char *, ...); | ||||||
| int		 xvasprintf(char **, const char *, va_list); | int		 xvasprintf(char **, const char *, va_list); | ||||||
| int printflike3	 xsnprintf(char *, size_t, const char *, ...); | int printflike3	 xsnprintf(char *, size_t, const char *, ...); | ||||||
|   | |||||||
| @@ -384,7 +384,7 @@ tty_keys_free1(struct tty_key *tk) | |||||||
| 		tty_keys_free1(tk->left); | 		tty_keys_free1(tk->left); | ||||||
| 	if (tk->right != NULL) | 	if (tk->right != NULL) | ||||||
| 		tty_keys_free1(tk->right); | 		tty_keys_free1(tk->right); | ||||||
| 	xfree(tk); | 	free(tk); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Lookup a key in the tree. */ | /* Lookup a key in the tree. */ | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								tty-term.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								tty-term.c
									
									
									
									
									
								
							| @@ -255,7 +255,7 @@ tty_term_override(struct tty_term *term, const char *overrides) | |||||||
| 				*ptr++ = '\0'; | 				*ptr++ = '\0'; | ||||||
| 				val = xstrdup(ptr); | 				val = xstrdup(ptr); | ||||||
| 				if (strunvis(val, ptr) == -1) { | 				if (strunvis(val, ptr) == -1) { | ||||||
| 					xfree(val); | 					free(val); | ||||||
| 					val = xstrdup(ptr); | 					val = xstrdup(ptr); | ||||||
| 				} | 				} | ||||||
| 			} else if (entstr[strlen(entstr) - 1] == '@') { | 			} else if (entstr[strlen(entstr) - 1] == '@') { | ||||||
| @@ -281,7 +281,7 @@ tty_term_override(struct tty_term *term, const char *overrides) | |||||||
| 					break; | 					break; | ||||||
| 				case TTYCODE_STRING: | 				case TTYCODE_STRING: | ||||||
| 					if (code->type == TTYCODE_STRING) | 					if (code->type == TTYCODE_STRING) | ||||||
| 						xfree(code->value.string); | 						free(code->value.string); | ||||||
| 					code->value.string = xstrdup(val); | 					code->value.string = xstrdup(val); | ||||||
| 					code->type = ent->type; | 					code->type = ent->type; | ||||||
| 					break; | 					break; | ||||||
| @@ -299,12 +299,11 @@ tty_term_override(struct tty_term *term, const char *overrides) | |||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			if (val != NULL) | 			free(val); | ||||||
| 				xfree(val); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(s); | 	free(s); | ||||||
| } | } | ||||||
|  |  | ||||||
| struct tty_term * | struct tty_term * | ||||||
| @@ -468,10 +467,10 @@ tty_term_free(struct tty_term *term) | |||||||
|  |  | ||||||
| 	for (i = 0; i < NTTYCODE; i++) { | 	for (i = 0; i < NTTYCODE; i++) { | ||||||
| 		if (term->codes[i].type == TTYCODE_STRING) | 		if (term->codes[i].type == TTYCODE_STRING) | ||||||
| 			xfree(term->codes[i].value.string); | 			free(term->codes[i].value.string); | ||||||
| 	} | 	} | ||||||
| 	xfree(term->name); | 	free(term->name); | ||||||
| 	xfree(term); | 	free(term); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								tty.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								tty.c
									
									
									
									
									
								
							| @@ -345,11 +345,11 @@ tty_free(struct tty *tty) | |||||||
| { | { | ||||||
| 	tty_close(tty); | 	tty_close(tty); | ||||||
|  |  | ||||||
| 	xfree(tty->ccolour); | 	free(tty->ccolour); | ||||||
| 	if (tty->path != NULL) | 	if (tty->path != NULL) | ||||||
| 		xfree(tty->path); | 		free(tty->path); | ||||||
| 	if (tty->termname != NULL) | 	if (tty->termname != NULL) | ||||||
| 		xfree(tty->termname); | 		free(tty->termname); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
| @@ -468,7 +468,7 @@ tty_force_cursor_colour(struct tty *tty, const char *ccolour) | |||||||
| 		tty_putcode(tty, TTYC_CR); | 		tty_putcode(tty, TTYC_CR); | ||||||
| 	else | 	else | ||||||
| 		tty_putcode_ptr1(tty, TTYC_CC, ccolour); | 		tty_putcode_ptr1(tty, TTYC_CC, ccolour); | ||||||
| 	xfree(tty->ccolour); | 	free(tty->ccolour); | ||||||
| 	tty->ccolour = xstrdup(ccolour); | 	tty->ccolour = xstrdup(ccolour); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -1099,7 +1099,7 @@ tty_cmd_setselection(struct tty *tty, const struct tty_ctx *ctx) | |||||||
| 	b64_ntop(ctx->ptr, ctx->num, buf, off); | 	b64_ntop(ctx->ptr, ctx->num, buf, off); | ||||||
| 	tty_putcode_ptr2(tty, TTYC_MS, "", buf); | 	tty_putcode_ptr2(tty, TTYC_MS, "", buf); | ||||||
|  |  | ||||||
| 	xfree(buf); | 	free(buf); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
| @@ -152,12 +153,12 @@ window_choose_free(struct window_pane *wp) | |||||||
| 		item = &ARRAY_ITEM(&data->list, i); | 		item = &ARRAY_ITEM(&data->list, i); | ||||||
| 		if (data->freefn != NULL && item->wcd != NULL) | 		if (data->freefn != NULL && item->wcd != NULL) | ||||||
| 			data->freefn(item->wcd); | 			data->freefn(item->wcd); | ||||||
| 		xfree(item->name); | 		free(item->name); | ||||||
| 	} | 	} | ||||||
| 	ARRAY_FREE(&data->list); | 	ARRAY_FREE(&data->list); | ||||||
|  |  | ||||||
| 	screen_free(&data->screen); | 	screen_free(&data->screen); | ||||||
| 	xfree(data); | 	free(data); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
| @@ -493,7 +494,7 @@ window_choose_ctx(struct window_choose_data *cdata) | |||||||
| 		if (cause != NULL) { | 		if (cause != NULL) { | ||||||
| 			*cause = toupper((u_char) *cause); | 			*cause = toupper((u_char) *cause); | ||||||
| 			status_message_set(cdata->client, "%s", cause); | 			status_message_set(cdata->client, "%s", cause); | ||||||
| 			xfree(cause); | 			free(cause); | ||||||
| 		} | 		} | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| @@ -544,7 +545,7 @@ window_choose_add_window(struct window_pane *wp, struct cmd_ctx *ctx, | |||||||
|  |  | ||||||
| 	xasprintf(&action_data, "%s:%d", s->name, wl->idx); | 	xasprintf(&action_data, "%s:%d", s->name, wl->idx); | ||||||
| 	wcd->command = cmd_template_replace(action, action_data, 1); | 	wcd->command = cmd_template_replace(action, action_data, 1); | ||||||
| 	xfree(action_data); | 	free(action_data); | ||||||
|  |  | ||||||
| 	wcd->idx = wl->idx; | 	wcd->idx = wl->idx; | ||||||
| 	wcd->ft_template = xstrdup(template); | 	wcd->ft_template = xstrdup(template); | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
|  |  | ||||||
|  | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
|  |  | ||||||
| @@ -69,7 +70,7 @@ window_clock_free(struct window_pane *wp) | |||||||
| 	struct window_clock_mode_data	*data = wp->modedata; | 	struct window_clock_mode_data	*data = wp->modedata; | ||||||
|  |  | ||||||
| 	screen_free(&data->screen); | 	screen_free(&data->screen); | ||||||
| 	xfree(data); | 	free(data); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
|   | |||||||
| @@ -240,17 +240,16 @@ window_copy_free(struct window_pane *wp) | |||||||
| 	if (wp->fd != -1) | 	if (wp->fd != -1) | ||||||
| 		bufferevent_enable(wp->event, EV_READ|EV_WRITE); | 		bufferevent_enable(wp->event, EV_READ|EV_WRITE); | ||||||
|  |  | ||||||
| 	if (data->searchstr != NULL) | 	free(data->searchstr); | ||||||
| 		xfree(data->searchstr); | 	free(data->inputstr); | ||||||
| 	xfree(data->inputstr); |  | ||||||
|  |  | ||||||
| 	if (data->backing != &wp->base) { | 	if (data->backing != &wp->base) { | ||||||
| 		screen_free(data->backing); | 		screen_free(data->backing); | ||||||
| 		xfree(data->backing); | 		free(data->backing); | ||||||
| 	} | 	} | ||||||
| 	screen_free(&data->screen); | 	screen_free(&data->screen); | ||||||
|  |  | ||||||
| 	xfree(data); | 	free(data); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
| @@ -1379,7 +1378,7 @@ window_copy_copy_selection(struct window_pane *wp, int idx) | |||||||
|  |  | ||||||
| 	/* Don't bother if no data. */ | 	/* Don't bother if no data. */ | ||||||
| 	if (off == 0) { | 	if (off == 0) { | ||||||
| 		xfree(buf); | 		free(buf); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	off--;	/* remove final \n */ | 	off--;	/* remove final \n */ | ||||||
|   | |||||||
							
								
								
									
										37
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								window.c
									
									
									
									
									
								
							| @@ -176,9 +176,8 @@ winlink_remove(struct winlinks *wwl, struct winlink *wl) | |||||||
| 	struct window	*w = wl->window; | 	struct window	*w = wl->window; | ||||||
|  |  | ||||||
| 	RB_REMOVE(winlinks, wwl, wl); | 	RB_REMOVE(winlinks, wwl, wl); | ||||||
| 	if (wl->status_text != NULL) | 	free(wl->status_text); | ||||||
| 		xfree(wl->status_text); | 	free(wl); | ||||||
| 	xfree(wl); |  | ||||||
|  |  | ||||||
| 	if (w != NULL) { | 	if (w != NULL) { | ||||||
| 		if (w->references == 0) | 		if (w->references == 0) | ||||||
| @@ -356,16 +355,14 @@ window_destroy(struct window *w) | |||||||
|  |  | ||||||
| 	window_destroy_panes(w); | 	window_destroy_panes(w); | ||||||
|  |  | ||||||
| 	if (w->name != NULL) | 	free(w->name); | ||||||
| 		xfree(w->name); | 	free(w); | ||||||
| 	xfree(w); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
| window_set_name(struct window *w, const char *new_name) | window_set_name(struct window *w, const char *new_name) | ||||||
| { | { | ||||||
| 	if (w->name != NULL) | 	free(w->name); | ||||||
| 		xfree(w->name); |  | ||||||
| 	w->name = xstrdup(new_name); | 	w->name = xstrdup(new_name); | ||||||
| 	notify_window_renamed(w); | 	notify_window_renamed(w); | ||||||
| } | } | ||||||
| @@ -668,13 +665,10 @@ window_pane_destroy(struct window_pane *wp) | |||||||
|  |  | ||||||
| 	RB_REMOVE(window_pane_tree, &all_window_panes, wp); | 	RB_REMOVE(window_pane_tree, &all_window_panes, wp); | ||||||
|  |  | ||||||
| 	if (wp->cwd != NULL) | 	free(wp->cwd); | ||||||
| 		xfree(wp->cwd); | 	free(wp->shell); | ||||||
| 	if (wp->shell != NULL) | 	free(wp->cmd); | ||||||
| 		xfree(wp->shell); | 	free(wp); | ||||||
| 	if (wp->cmd != NULL) |  | ||||||
| 		xfree(wp->cmd); |  | ||||||
| 	xfree(wp); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
| @@ -691,18 +685,15 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell, | |||||||
| 		close(wp->fd); | 		close(wp->fd); | ||||||
| 	} | 	} | ||||||
| 	if (cmd != NULL) { | 	if (cmd != NULL) { | ||||||
| 		if (wp->cmd != NULL) | 		free(wp->cmd); | ||||||
| 			xfree(wp->cmd); |  | ||||||
| 		wp->cmd = xstrdup(cmd); | 		wp->cmd = xstrdup(cmd); | ||||||
| 	} | 	} | ||||||
| 	if (shell != NULL) { | 	if (shell != NULL) { | ||||||
| 		if (wp->shell != NULL) | 		free(wp->shell); | ||||||
| 			xfree(wp->shell); |  | ||||||
| 		wp->shell = xstrdup(shell); | 		wp->shell = xstrdup(shell); | ||||||
| 	} | 	} | ||||||
| 	if (cwd != NULL) { | 	if (cwd != NULL) { | ||||||
| 		if (wp->cwd != NULL) | 		free(wp->cwd); | ||||||
| 			xfree(wp->cwd); |  | ||||||
| 		wp->cwd = xstrdup(cwd); | 		wp->cwd = xstrdup(cwd); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -1058,10 +1049,10 @@ window_pane_search(struct window_pane *wp, const char *searchstr, u_int *lineno) | |||||||
| 				*lineno = i; | 				*lineno = i; | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 		xfree(line); | 		free(line); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xfree(newsearchstr); | 	free(newsearchstr); | ||||||
| 	return (msg); | 	return (msg); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -82,14 +82,6 @@ xrealloc(void *oldptr, size_t nmemb, size_t size) | |||||||
| 	return (newptr); | 	return (newptr); | ||||||
| } | } | ||||||
|  |  | ||||||
| void |  | ||||||
| xfree(void *ptr) |  | ||||||
| { |  | ||||||
| 	if (ptr == NULL) |  | ||||||
| 		fatalx("null pointer"); |  | ||||||
| 	free(ptr); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| int printflike2 | int printflike2 | ||||||
| xasprintf(char **ret, const char *fmt, ...) | xasprintf(char **ret, const char *fmt, ...) | ||||||
| { | { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tiago Cunha
					Tiago Cunha