diff options
author | Alexander Orzechowski <alex@ozal.ski> | 2023-06-12 11:56:20 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-06-12 18:24:00 +0000 |
commit | a09bb1314de6296545aae5146658ac1259ae6c40 (patch) | |
tree | c1deda7942335d47ba93513772e22e0a98266e3c | |
parent | b80e67d6e6615ea6fa9bd58e69764a4f0726d47e (diff) |
wlr_output_state: Consider gamma_lut uninitialized if not committed
-rw-r--r-- | types/output/state.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/types/output/state.c b/types/output/state.c index fb3c886d..761c419a 100644 --- a/types/output/state.c +++ b/types/output/state.c @@ -14,7 +14,9 @@ void wlr_output_state_finish(struct wlr_output_state *state) { if (state->committed & WLR_OUTPUT_STATE_DAMAGE) { pixman_region32_fini(&state->damage); } - free(state->gamma_lut); + if (state->committed & WLR_OUTPUT_STATE_GAMMA_LUT) { + free(state->gamma_lut); + } } void wlr_output_state_set_enabled(struct wlr_output_state *state, @@ -97,7 +99,11 @@ bool wlr_output_state_set_gamma_lut(struct wlr_output_state *state, size_t ramp_size, const uint16_t *r, const uint16_t *g, const uint16_t *b) { uint16_t *gamma_lut = NULL; if (ramp_size > 0) { - gamma_lut = realloc(state->gamma_lut, 3 * ramp_size * sizeof(uint16_t)); + if (state->committed & WLR_OUTPUT_STATE_GAMMA_LUT) { + gamma_lut = realloc(state->gamma_lut, 3 * ramp_size * sizeof(uint16_t)); + } else { + gamma_lut = malloc(3 * ramp_size * sizeof(uint16_t)); + } if (gamma_lut == NULL) { wlr_log_errno(WLR_ERROR, "Allocation failed"); return false; |