mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	cmd_find_client shouldn't die when there is an empty slot in the clients
array. DOH.
This commit is contained in:
		
							
								
								
									
										15
									
								
								cmd.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								cmd.c
									
									
									
									
									
								
							@@ -399,7 +399,7 @@ cmd_newest_client(void)
 | 
			
		||||
struct client *
 | 
			
		||||
cmd_find_client(struct cmd_ctx *ctx, const char *arg)
 | 
			
		||||
{
 | 
			
		||||
	struct client	*c;
 | 
			
		||||
	struct client	*c, *lastc;
 | 
			
		||||
	struct session	*s;
 | 
			
		||||
	char		*tmparg;
 | 
			
		||||
	size_t		 arglen;
 | 
			
		||||
@@ -415,16 +415,17 @@ cmd_find_client(struct cmd_ctx *ctx, const char *arg)
 | 
			
		||||
		 */
 | 
			
		||||
		s = cmd_current_session(ctx);
 | 
			
		||||
		if (s != NULL) {
 | 
			
		||||
			c = NULL;
 | 
			
		||||
			lastc = NULL;
 | 
			
		||||
			for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
			
		||||
				if (ARRAY_ITEM(&clients, i)->session == s) {
 | 
			
		||||
					if (c != NULL)
 | 
			
		||||
				c = ARRAY_ITEM(&clients, i);
 | 
			
		||||
				if (c != NULL && c->session == s) {
 | 
			
		||||
					if (lastc != NULL)
 | 
			
		||||
						break;
 | 
			
		||||
					c = ARRAY_ITEM(&clients, i);
 | 
			
		||||
					lastc = c;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if (i == ARRAY_LENGTH(&clients) && c != NULL)
 | 
			
		||||
				return (c);
 | 
			
		||||
			if (i == ARRAY_LENGTH(&clients) && lastc != NULL)
 | 
			
		||||
				return (lastc);
 | 
			
		||||
		}
 | 
			
		||||
		return (cmd_newest_client());
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user