[Cogl] [PATCH 2/2] Fix freeing an atlas texture that hasn't been allocated

Robert Bragg robert at sixbynine.org
Wed Jun 12 03:42:11 PDT 2013


This looks good to land to me:

Reviewed-by: Robert Bragg <robert at linux.intel.com>

thanks,
- Robert

On Tue, Jun 11, 2013 at 3:57 PM, Neil Roberts <neil at linux.intel.com> wrote:
> 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.
> ---
>  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 bbf08e6..747a6c9 100644
> --- a/cogl/cogl-atlas-texture.c
> +++ b/cogl/cogl-atlas-texture.c
> @@ -278,7 +278,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 02f0256..81e38d6 100644
> --- a/tests/conform/test-conform-main.c
> +++ b/tests/conform/test-conform-main.c
> @@ -141,7 +141,7 @@ main (int argc, char **argv)
>
>    ADD_TEST (test_fence, TEST_REQUIREMENT_FENCE, 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]);
>
> --
> 1.7.11.3.g3c3efa5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl


More information about the Cogl mailing list