[Mesa-dev] [PATCH] st/mesa: fix resource leak in try_pbo_readpixels

Ilia Mirkin imirkin at alum.mit.edu
Thu Jun 2 20:53:26 UTC 2016


On Thu, Jun 2, 2016 at 4:50 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> Found by inspection after seeing
> https://bugs.freedesktop.org/show_bug.cgi?id=96343
> ---
>  src/mesa/state_tracker/st_cb_readpixels.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
> index 6df3a39..f42ff20 100644
> --- a/src/mesa/state_tracker/st_cb_readpixels.c
> +++ b/src/mesa/state_tracker/st_cb_readpixels.c
> @@ -170,6 +170,8 @@ try_pbo_readpixels(struct st_context *st, struct st_renderbuffer *strb,
>        image.u.buf.last_element = addr.last_element;
>
>        cso_set_shader_images(cso, PIPE_SHADER_FRAGMENT, 0, 1, &image);
> +
> +      pipe_resource_reference(&image.resource, NULL);

Instead would it be cleaner to not do this at all, and just do

image.resource = addr.buffer

above, instead of doing the whole reference thing. As far as I can
tell, you're not protecting against anything by grabbing the extra
reference.

  -ilia


More information about the mesa-dev mailing list