From 128e981f6cf6e9a5b32da1b908d83f6c01d384fa Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 6 Sep 2010 17:50:57 +0100 Subject: [PATCH] texture: Do some more validation in get_cogl_texture() Check the layer type, even though right now we only have one type available. --- clutter/clutter-texture.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 40b530f..04d5270 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -1306,7 +1306,6 @@ clutter_texture_set_cogl_material (ClutterTexture *texture, cogl_handle_ref (cogl_material); - /* This */ if (texture->priv->material) cogl_handle_unref (texture->priv->material); @@ -1341,16 +1340,24 @@ clutter_texture_set_cogl_material (ClutterTexture *texture, CoglHandle clutter_texture_get_cogl_texture (ClutterTexture *texture) { + CoglMaterialLayerType layer_type; const GList *layers; int n_layers; g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), COGL_INVALID_HANDLE); layers = cogl_material_get_layers (texture->priv->material); + if (layers == NULL) + return COGL_INVALID_HANDLE; + n_layers = g_list_length ((GList *)layers); if (n_layers == 0) return COGL_INVALID_HANDLE; + layer_type = cogl_material_layer_get_type (layers->data); + if (layer_type != COGL_MATERIAL_LAYER_TYPE_TEXTURE) + return COGL_INVALID_HANDLE; + return cogl_material_layer_get_texture (layers->data); } -- 2.7.4