mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	wayland-server: send error on invalid new object id
Creation of new client resources was silently ignored when wl_client_add_resource() was used on server side and new object id was out of range. An error is now send out to the client in such case. Also changed error message in wl_client_add_object, since wl_map_insert_at() returns -1 only at invalid new id.
This commit is contained in:
		
							parent
							
								
									76bfd68f47
								
							
						
					
					
						commit
						900e4b63ef
					
				
					 1 changed files with 10 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -395,9 +395,12 @@ wl_client_add_resource(struct wl_client *client,
 | 
			
		|||
		resource->object.id =
 | 
			
		||||
			wl_map_insert_new(&client->objects,
 | 
			
		||||
					  WL_MAP_SERVER_SIDE, resource);
 | 
			
		||||
	else
 | 
			
		||||
		wl_map_insert_at(&client->objects,
 | 
			
		||||
				 resource->object.id, resource);
 | 
			
		||||
	else if (wl_map_insert_at(&client->objects,
 | 
			
		||||
				  resource->object.id, resource) < 0)
 | 
			
		||||
		wl_resource_post_error(client->display_resource,
 | 
			
		||||
				       WL_DISPLAY_ERROR_INVALID_OBJECT,
 | 
			
		||||
				       "invalid new id %d",
 | 
			
		||||
				       resource->object.id);
 | 
			
		||||
 | 
			
		||||
	resource->client = client;
 | 
			
		||||
	wl_signal_init(&resource->destroy_signal);
 | 
			
		||||
| 
						 | 
				
			
			@ -1277,7 +1280,10 @@ wl_client_add_object(struct wl_client *client,
 | 
			
		|||
	wl_signal_init(&resource->destroy_signal);
 | 
			
		||||
 | 
			
		||||
	if (wl_map_insert_at(&client->objects, resource->object.id, resource) < 0) {
 | 
			
		||||
		wl_resource_post_no_memory(client->display_resource);
 | 
			
		||||
		wl_resource_post_error(client->display_resource,
 | 
			
		||||
				       WL_DISPLAY_ERROR_INVALID_OBJECT,
 | 
			
		||||
				       "invalid new id %d",
 | 
			
		||||
				       resource->object.id);
 | 
			
		||||
		free(resource);
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue