mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-03 16:46:18 +00:00 
			
		
		
		
	Fix previous not to leak fd on failure, whoops.
This commit is contained in:
		
							
								
								
									
										12
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								tmux.c
									
									
									
									
									
								
							@@ -129,21 +129,23 @@ get_full_path(const char *wd, const char *path)
 | 
			
		||||
{
 | 
			
		||||
	int		 fd;
 | 
			
		||||
	static char	 newpath[MAXPATHLEN];
 | 
			
		||||
	const char	*retval;
 | 
			
		||||
 | 
			
		||||
	fd = open(".", O_RDONLY);
 | 
			
		||||
	if (fd == -1)
 | 
			
		||||
		return (NULL);
 | 
			
		||||
 | 
			
		||||
	if (chdir(wd) != 0)
 | 
			
		||||
		return (NULL);
 | 
			
		||||
	if (realpath(path, newpath) != 0)
 | 
			
		||||
		return (NULL);
 | 
			
		||||
	retval = NULL;
 | 
			
		||||
	if (chdir(wd) == 0) {
 | 
			
		||||
		if (realpath(path, newpath) == 0)
 | 
			
		||||
			retval = newpath;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (fchdir(fd) != 0)
 | 
			
		||||
		chdir("/");
 | 
			
		||||
	close(fd);
 | 
			
		||||
 | 
			
		||||
	return (newpath);
 | 
			
		||||
	return (retval);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user