mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	wayland-server: Avoid deferencing a NULL pointer in error case
Reorder the error handling in the case that closure is NULL due to ENOMEM to ensure that we can safely call wl_closure_lookup_objects on the second test. Prior to this reordering the closure would be deferenced in the ENOMEM case due to the invocation of the second half of the logical OR check.
This commit is contained in:
		
							parent
							
								
									728b64189b
								
							
						
					
					
						commit
						8680c67c47
					
				
					 1 changed files with 5 additions and 5 deletions
				
			
		| 
						 | 
					@ -260,8 +260,11 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
 | 
				
			||||||
						  &client->objects, message);
 | 
											  &client->objects, message);
 | 
				
			||||||
		len -= size;
 | 
							len -= size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if ((closure == NULL && errno == EINVAL) ||
 | 
							if (closure == NULL && errno == ENOMEM) {
 | 
				
			||||||
		    wl_closure_lookup_objects(closure, &client->objects) < 0) {
 | 
								wl_resource_post_no_memory(resource);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							} else if ((closure == NULL && errno == EINVAL) ||
 | 
				
			||||||
 | 
								   wl_closure_lookup_objects(closure, &client->objects) < 0) {
 | 
				
			||||||
			wl_resource_post_error(client->display_resource,
 | 
								wl_resource_post_error(client->display_resource,
 | 
				
			||||||
					       WL_DISPLAY_ERROR_INVALID_METHOD,
 | 
										       WL_DISPLAY_ERROR_INVALID_METHOD,
 | 
				
			||||||
					       "invalid arguments for %s@%u.%s",
 | 
										       "invalid arguments for %s@%u.%s",
 | 
				
			||||||
| 
						 | 
					@ -269,9 +272,6 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
 | 
				
			||||||
					       object->id,
 | 
										       object->id,
 | 
				
			||||||
					       message->name);
 | 
										       message->name);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		} else if (closure == NULL && errno == ENOMEM) {
 | 
					 | 
				
			||||||
			wl_resource_post_no_memory(resource);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (wl_debug)
 | 
							if (wl_debug)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue