snapshot: Don't crash and don't leak

We were trying to handle a NULL mask child, unsuccessfully.

Pointed out by Niels De Graef.
This commit is contained in:
Matthias Clasen 2024-06-29 09:30:44 -04:00
parent 7d3970546c
commit 346fcdb405

View File

@ -1530,16 +1530,17 @@ gtk_snapshot_collect_mask_source (GtkSnapshot *snapshot,
{
GskRenderNode *source_child, *mask_child, *mask_node;
mask_child = gsk_render_node_ref (state->data.mask.mask_node);
mask_child = state->data.mask.mask_node;
source_child = gtk_snapshot_collect_default (snapshot, state, nodes, n_nodes);
if (source_child == NULL || mask_child == NULL)
if (source_child == NULL)
return NULL;
if (mask_child)
mask_node = gsk_mask_node_new (source_child, mask_child, state->data.mask.mask_mode);
else
mask_node = NULL;
gsk_render_node_unref (source_child);
gsk_render_node_unref (mask_child);
return mask_node;
}