aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Orzechowski <alex@ozal.ski>2023-06-12 10:34:32 -0400
committerSimon Ser <contact@emersion.fr>2023-06-12 18:24:00 +0000
commitb80e67d6e6615ea6fa9bd58e69764a4f0726d47e (patch)
tree2e1ae8c49bb33964ade87cb5bbdc1ccf5132f579
parent96f1fdd113e7e6b953016a53b483adab338406bc (diff)
wlr_output_state: Consider buffer uninitialized if not committed
-rw-r--r--types/output/state.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/types/output/state.c b/types/output/state.c
index 0bb384a8..fb3c886d 100644
--- a/types/output/state.c
+++ b/types/output/state.c
@@ -4,11 +4,13 @@
#include "types/wlr_output.h"
void wlr_output_state_finish(struct wlr_output_state *state) {
- wlr_buffer_unlock(state->buffer);
- // struct wlr_buffer is ref'counted, so the pointer may remain valid after
- // wlr_buffer_unlock(). Reset the field to NULL to ensure nobody mistakenly
- // reads it after output_state_finish().
- state->buffer = NULL;
+ if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
+ wlr_buffer_unlock(state->buffer);
+ // struct wlr_buffer is ref'counted, so the pointer may remain valid after
+ // wlr_buffer_unlock(). Reset the field to NULL to ensure nobody mistakenly
+ // reads it after output_state_finish().
+ state->buffer = NULL;
+ }
if (state->committed & WLR_OUTPUT_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,
struct wlr_buffer *buffer) {
+ if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
+ wlr_buffer_unlock(state->buffer);
+ }
+
state->committed |= WLR_OUTPUT_STATE_BUFFER;
- wlr_buffer_unlock(state->buffer);
state->buffer = wlr_buffer_lock(buffer);
}