mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	server: move memset after check
If the malloc fails, memset would touch invalid memory. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
		
							parent
							
								
									e2c0d47b0c
								
							
						
					
					
						commit
						a92efe9ad6
					
				
					 1 changed files with 2 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1141,10 +1141,11 @@ wl_display_add_socket_auto(struct wl_display *display)
 | 
			
		|||
	const int MAX_DISPLAYNO = 32;
 | 
			
		||||
 | 
			
		||||
	s = malloc(sizeof *s);
 | 
			
		||||
	memset(s, 0, sizeof *s);
 | 
			
		||||
	if (s == NULL)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	memset(s, 0, sizeof *s);
 | 
			
		||||
 | 
			
		||||
	do {
 | 
			
		||||
		snprintf(display_name, sizeof display_name, "wayland-%d", displayno);
 | 
			
		||||
		if (wl_socket_init_for_display_name(s, display_name) < 0) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue