[Mesa-dev] [PATCH] st/mesa: add null pointer check in st_renderbuffer_delete()

Jose Fonseca jfonseca at vmware.com
Tue Dec 4 06:08:06 PST 2012


We'll leak strb->surface, but I suspect there is no solution other than fixing the use of surfaces by contexts that didn't create them.

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

----- Original Message -----
> From: Brian Paul <brianp at vmware.com>
> 
> In my testing I haven't found any cases where we get a null context
> pointer, but it might still be possible.  Check for null just to be
> safe.
> 
> Note: This is a candidate for the stable branches.
> ---
>  src/mesa/state_tracker/st_cb_fbo.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_cb_fbo.c
> b/src/mesa/state_tracker/st_cb_fbo.c
> index 04907c9..ae280bf 100644
> --- a/src/mesa/state_tracker/st_cb_fbo.c
> +++ b/src/mesa/state_tracker/st_cb_fbo.c
> @@ -228,10 +228,10 @@ static void
>  st_renderbuffer_delete(struct gl_context *ctx, struct
>  gl_renderbuffer *rb)
>  {
>     struct st_renderbuffer *strb = st_renderbuffer(rb);
> -   struct st_context *st = st_context(ctx);
> -   struct pipe_context *pipe = st->pipe;
> -
> -   pipe_surface_release(pipe, &strb->surface);
> +   if (ctx) {
> +      struct st_context *st = st_context(ctx);
> +      pipe_surface_release(st->pipe, &strb->surface);
> +   }
>     pipe_resource_reference(&strb->texture, NULL);
>     free(strb->data);
>     _mesa_delete_renderbuffer(ctx, rb);
> --
> 1.7.4.1
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list