[Mesa-dev] [PATCH 03/13] mesa/main: Don't go freeing texture data which was never allocated

Brian Paul brianp at vmware.com
Mon Dec 1 07:41:58 PST 2014


On 11/28/2014 04:25 AM, Juha-Pekka Heikkila wrote:
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
>   src/mesa/main/texstate.c | 13 +++++++++----
>   1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
> index e0f0852..7f29208 100644
> --- a/src/mesa/main/texstate.c
> +++ b/src/mesa/main/texstate.c
> @@ -930,14 +930,19 @@ _mesa_free_texture_data(struct gl_context *ctx)
>      }
>
>      /* Free proxy texture objects */
> -   for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++)
> -      ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]);
> +   for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
> +      if (ctx->Texture.ProxyTex[tgt])
> +         ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]);
> +   }
>
>      /* GL_ARB_texture_buffer_object */
> -   _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL);
> +   if (ctx->Texture.BufferObject)
> +      _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL);
>
>      for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
> -      _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL);
> +      if (ctx->Texture.Unit[u].Sampler)
> +         _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler,
> +                                        NULL);
>      }
>   }

I don't understand those last two conditionals.  If the pointer is 
already null, calling _mesa_reference_foo() shouldn't matter, right?

-Brian




More information about the mesa-dev mailing list