llvmpipe: use pipe_sampler_view_release() to avoid segfault
authorJonathan Liu <net147@gmail.com>
Mon, 16 Dec 2013 01:24:00 +0000 (18:24 -0700)
committerBrian Paul <brianp@vmware.com>
Sun, 22 Dec 2013 14:07:56 +0000 (07:07 -0700)
This fixes another case of faulting when freeing a pipe_sampler_view
that belongs to a previously destroyed context.

Cc: "10.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Jonathan Liu <net147@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/llvmpipe/lp_state_sampler.c

index 1d3db0f25c7aa47b7341a9bdb406b05f5483363d..ff498f7f15a04617853c0b948603df2083614f8f 100644 (file)
@@ -136,6 +136,12 @@ llvmpipe_set_sampler_views(struct pipe_context *pipe,
 
    /* set the new sampler views */
    for (i = 0; i < num; i++) {
+      /* Note: we're using pipe_sampler_view_release() here to work around
+       * a possible crash when the old view belongs to another context that
+       * was already destroyed.
+       */
+      pipe_sampler_view_release(pipe,
+                                &llvmpipe->sampler_views[shader][start + i]);
       pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][start + i],
                                   views[i]);
    }