mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	wlr_output_state: Consider buffer uninitialized if not committed
This commit is contained in:
		
							parent
							
								
									96f1fdd113
								
							
						
					
					
						commit
						b80e67d6e6
					
				
					 1 changed files with 11 additions and 6 deletions
				
			
		| 
						 | 
					@ -4,11 +4,13 @@
 | 
				
			||||||
#include "types/wlr_output.h"
 | 
					#include "types/wlr_output.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_output_state_finish(struct wlr_output_state *state) {
 | 
					void wlr_output_state_finish(struct wlr_output_state *state) {
 | 
				
			||||||
	wlr_buffer_unlock(state->buffer);
 | 
						if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
 | 
				
			||||||
	// struct wlr_buffer is ref'counted, so the pointer may remain valid after
 | 
							wlr_buffer_unlock(state->buffer);
 | 
				
			||||||
	// wlr_buffer_unlock(). Reset the field to NULL to ensure nobody mistakenly
 | 
							// struct wlr_buffer is ref'counted, so the pointer may remain valid after
 | 
				
			||||||
	// reads it after output_state_finish().
 | 
							// wlr_buffer_unlock(). Reset the field to NULL to ensure nobody mistakenly
 | 
				
			||||||
	state->buffer = NULL;
 | 
							// reads it after output_state_finish().
 | 
				
			||||||
 | 
							state->buffer = NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (state->committed & WLR_OUTPUT_STATE_DAMAGE) {
 | 
						if (state->committed & WLR_OUTPUT_STATE_DAMAGE) {
 | 
				
			||||||
		pixman_region32_fini(&state->damage);
 | 
							pixman_region32_fini(&state->damage);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -71,8 +73,11 @@ void wlr_output_state_set_subpixel(struct wlr_output_state *state,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_output_state_set_buffer(struct wlr_output_state *state,
 | 
					void wlr_output_state_set_buffer(struct wlr_output_state *state,
 | 
				
			||||||
		struct wlr_buffer *buffer) {
 | 
							struct wlr_buffer *buffer) {
 | 
				
			||||||
 | 
						if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
 | 
				
			||||||
 | 
							wlr_buffer_unlock(state->buffer);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	state->committed |= WLR_OUTPUT_STATE_BUFFER;
 | 
						state->committed |= WLR_OUTPUT_STATE_BUFFER;
 | 
				
			||||||
	wlr_buffer_unlock(state->buffer);
 | 
					 | 
				
			||||||
	state->buffer = wlr_buffer_lock(buffer);
 | 
						state->buffer = wlr_buffer_lock(buffer);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue