mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-26 21:59:18 +01:00
Unset plane->layer and layer->plane on destroy
This fixes a use-after-free when destroying a layer/plane early.
This commit is contained in:
parent
333e454e98
commit
99ef3d5b2e
2 changed files with 6 additions and 0 deletions
3
layer.c
3
layer.c
|
@ -20,6 +20,9 @@ struct liftoff_layer *liftoff_layer_create(struct liftoff_output *output)
|
|||
void liftoff_layer_destroy(struct liftoff_layer *layer)
|
||||
{
|
||||
layer->output->layers_changed = true;
|
||||
if (layer->plane != NULL) {
|
||||
layer->plane->layer = NULL;
|
||||
}
|
||||
if (layer->output->composition_layer == layer) {
|
||||
layer->output->composition_layer = NULL;
|
||||
}
|
||||
|
|
3
plane.c
3
plane.c
|
@ -130,6 +130,9 @@ struct liftoff_plane *plane_create(struct liftoff_device *device, uint32_t id)
|
|||
|
||||
void plane_destroy(struct liftoff_plane *plane)
|
||||
{
|
||||
if (plane->layer != NULL) {
|
||||
plane->layer->plane = NULL;
|
||||
}
|
||||
liftoff_list_remove(&plane->link);
|
||||
free(plane->props);
|
||||
free(plane);
|
||||
|
|
Loading…
Reference in a new issue