[cogl/cogl-1.14] Fix freeing an atlas texture that hasn't been allocated



commit c6dba9fc3e6a608432a6948522c59fb633603ba0
Author: Neil Roberts <neil linux intel com>
Date:   Tue Jun 11 15:57:38 2013 +0100

    Fix freeing an atlas texture that hasn't been allocated
    
    The free function for atlas textures was previously always assuming
    that there will be a valid sub_texture pointer but this might not be
    the case if the texture was never successfully allocated. This was
    causing Cogl to crash if the application tries to make a texture that
    can not fit in the atlas using the automagic texture API.
    
    Reviewed-by: Robert Bragg <robert linux intel com>
    
    (cherry picked from commit a7a8b7aefc8cb03fe8b716bee06b3449a7dba85f)
    
    Conflicts:
        tests/conform/test-conform-main.c

 cogl/cogl-atlas-texture.c         |    3 ++-
 tests/conform/test-conform-main.c |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c
index 7f62efc..30dd319 100644
--- a/cogl/cogl-atlas-texture.c
+++ b/cogl/cogl-atlas-texture.c
@@ -276,7 +276,8 @@ _cogl_atlas_texture_free (CoglAtlasTexture *atlas_tex)
 {
   _cogl_atlas_texture_remove_from_atlas (atlas_tex);
 
-  cogl_object_unref (atlas_tex->sub_texture);
+  if (atlas_tex->sub_texture)
+    cogl_object_unref (atlas_tex->sub_texture);
 
   /* Chain up */
   _cogl_texture_free (COGL_TEXTURE (atlas_tex));
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index 9c8c35e..c5a5d4c 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -132,7 +132,7 @@ main (int argc, char **argv)
 
   ADD_TEST (test_euler_quaternion, 0, 0);
 
-  ADD_TEST (test_texture_no_allocate, 0, TEST_KNOWN_FAILURE);
+  ADD_TEST (test_texture_no_allocate, 0, 0);
 
   g_printerr ("Unknown test name \"%s\"\n", argv[1]);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]