diff --git a/src/encoder_state-ctors_dtors.c b/src/encoder_state-ctors_dtors.c index 871b49bd..88c57eea 100644 --- a/src/encoder_state-ctors_dtors.c +++ b/src/encoder_state-ctors_dtors.c @@ -754,13 +754,16 @@ void kvz_encoder_state_finalize(encoder_state_t * const state) { if (!state->parent || (state->parent->slice != state->slice)) { + if (state->encoder_control->cfg.lmcs_enable) { + if (state->slice->lmcs_aps != NULL) { + FREE_POINTER(state->slice->lmcs_aps); + } + } + if (state->encoder_control->cfg.alf_type) { if (state->slice->apss != NULL) { FREE_POINTER(state->slice->apss); } - if (state->slice->lmcs_aps != NULL) { - FREE_POINTER(state->slice->lmcs_aps); - } if (state->slice->tile_group_luma_aps_id != NULL) { FREE_POINTER(state->slice->tile_group_luma_aps_id); }