mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Fix up window reference counting and don't crash if the rename timer
fires while the window is dead but still referenced. Fixes problem reported by Michael Scholz.
This commit is contained in:
		
							
								
								
									
										3
									
								
								names.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								names.c
									
									
									
									
									
								
							@@ -50,6 +50,9 @@ window_name_callback(unused int fd, unused short events, void *data)
 | 
			
		||||
	struct window	*w = data;
 | 
			
		||||
	char		*name, *wname;
 | 
			
		||||
 | 
			
		||||
	if (w->active == NULL)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	if (!options_get_number(&w->options, "automatic-rename")) {
 | 
			
		||||
		if (event_initialized(&w->name_timer))
 | 
			
		||||
			event_del(&w->name_timer);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								notify.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								notify.c
									
									
									
									
									
								
							@@ -125,7 +125,8 @@ notify_drain(void)
 | 
			
		||||
		if (ne->session != NULL)
 | 
			
		||||
			ne->session->references--;
 | 
			
		||||
		if (ne->window != NULL)
 | 
			
		||||
			ne->window->references--;
 | 
			
		||||
			window_remove_ref(ne->window);
 | 
			
		||||
 | 
			
		||||
		TAILQ_REMOVE(¬ify_queue, ne, entry);
 | 
			
		||||
		free(ne);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								tmux.h
									
									
									
									
									
								
							@@ -2130,6 +2130,7 @@ struct window_pane *window_pane_find_down(struct window_pane *);
 | 
			
		||||
struct window_pane *window_pane_find_left(struct window_pane *);
 | 
			
		||||
struct window_pane *window_pane_find_right(struct window_pane *);
 | 
			
		||||
void		 window_set_name(struct window *, const char *);
 | 
			
		||||
void		 window_remove_ref(struct window *);
 | 
			
		||||
void		 winlink_clear_flags(struct winlink *);
 | 
			
		||||
void		 window_mode_attrs(struct grid_cell *, struct options *);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										19
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								window.c
									
									
									
									
									
								
							@@ -182,13 +182,8 @@ winlink_remove(struct winlinks *wwl, struct winlink *wl)
 | 
			
		||||
	free(wl->status_text);
 | 
			
		||||
	free(wl);
 | 
			
		||||
 | 
			
		||||
	if (w != NULL) {
 | 
			
		||||
		if (w->references == 0)
 | 
			
		||||
			fatal("bad reference count");
 | 
			
		||||
		w->references--;
 | 
			
		||||
		if (w->references == 0)
 | 
			
		||||
			window_destroy(w);
 | 
			
		||||
	}
 | 
			
		||||
	if (w != NULL)
 | 
			
		||||
		window_remove_ref(w);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct winlink *
 | 
			
		||||
@@ -362,6 +357,16 @@ window_destroy(struct window *w)
 | 
			
		||||
	free(w);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
window_remove_ref(struct window *w)
 | 
			
		||||
{
 | 
			
		||||
	if (w->references == 0)
 | 
			
		||||
		fatal("bad reference count");
 | 
			
		||||
	w->references--;
 | 
			
		||||
	if (w->references == 0)
 | 
			
		||||
		window_destroy(w);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
window_set_name(struct window *w, const char *new_name)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user