svga: use pipe_sampler_view_release() to avoid segfault
authorBrian Paul <brianp@vmware.com>
Thu, 16 Feb 2012 19:23:16 +0000 (12:23 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 23 Feb 2012 14:49:09 +0000 (07:49 -0700)
This fixes another case of faulting when freeing a pipe_sampler_view
that belongs to a previously destroyed context.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/drivers/svga/svga_pipe_sampler.c

index 13c7b18..c1ea4f8 100644 (file)
@@ -225,8 +225,12 @@ svga_set_fragment_sampler_views(struct pipe_context *pipe,
    }
 
    for (i = 0; i < num; i++) {
-      pipe_sampler_view_reference(&svga->curr.sampler_views[i],
-                                  views[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, &svga->curr.sampler_views[i]);
+      pipe_sampler_view_reference(&svga->curr.sampler_views[i], views[i]);
 
       if (!views[i])
          continue;