From 472e8e8f4e325f1839b42b10dd38a4828e559909 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 5 Apr 2011 17:30:29 +0100 Subject: [PATCH] cogl-pipeline: Be careful not to take ownership of root layer In _cogl_pipeline_prune_empty_layer_difference if the layer's parent has no owner then it just takes ownership of it. However this could theoretically end up taking ownership of the root layer because according to the comment above in the same function that should never have an owner. This patch just adds an extra check to ensure that the unowned layer has a parent. http://bugzilla.clutter-project.org/show_bug.cgi?id=2588 --- cogl/cogl-pipeline.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c index 76d02ac38..acce53683 100644 --- a/cogl/cogl-pipeline.c +++ b/cogl/cogl-pipeline.c @@ -2189,9 +2189,11 @@ _cogl_pipeline_prune_empty_layer_difference (CoglPipeline *layers_authority, /* If the layer's parent doesn't have an owner then we can simply * take ownership ourselves and drop our reference on the empty - * layer. + * layer. We don't want to take ownership of the root node layer so + * we also need to verify that the parent has a parent */ - if (layer_parent->index == layer->index && layer_parent->owner == NULL) + if (layer_parent->index == layer->index && layer_parent->owner == NULL && + _cogl_pipeline_layer_get_parent (layer_parent) != NULL) { cogl_object_ref (layer_parent); layer_parent->owner = layers_authority;