mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	buffer: improve error handling
In case the texture can't be imported, release the buffer so that the client can submit another one. In case the allocation fails, disconnect the client.
This commit is contained in:
		
							parent
							
								
									efd294ef09
								
							
						
					
					
						commit
						96e8e9b098
					
				
					 1 changed files with 2 additions and 0 deletions
				
			
		| 
						 | 
					@ -96,12 +96,14 @@ struct wlr_buffer *wlr_buffer_create(struct wlr_renderer *renderer,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (texture == NULL) {
 | 
						if (texture == NULL) {
 | 
				
			||||||
		wlr_log(WLR_ERROR, "Failed to upload texture");
 | 
							wlr_log(WLR_ERROR, "Failed to upload texture");
 | 
				
			||||||
 | 
							wl_buffer_send_release(resource);
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_buffer *buffer = calloc(1, sizeof(struct wlr_buffer));
 | 
						struct wlr_buffer *buffer = calloc(1, sizeof(struct wlr_buffer));
 | 
				
			||||||
	if (buffer == NULL) {
 | 
						if (buffer == NULL) {
 | 
				
			||||||
		wlr_texture_destroy(texture);
 | 
							wlr_texture_destroy(texture);
 | 
				
			||||||
 | 
							wl_resource_post_no_memory(resource);
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	buffer->resource = resource;
 | 
						buffer->resource = resource;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue