softpipe: make sure that invalid calls to sosettargets don't crash us
authorZack Rusin <zack@kde.org>
Tue, 8 Jun 2010 20:18:38 +0000 (16:18 -0400)
committerZack Rusin <zack@kde.org>
Tue, 8 Jun 2010 20:18:38 +0000 (16:18 -0400)
src/gallium/drivers/softpipe/sp_state_so.c

index 8bd20cd2acaf10e3dd2e3f9cec1714b3232718a6..27acd3dfc12d8eb169f595b1214274274653f246 100644 (file)
@@ -96,6 +96,13 @@ softpipe_set_stream_output_buffers(struct pipe_context *pipe,
       void *mapped;
       struct softpipe_resource *res = softpipe_resource(buffers[i]);
 
+      if (!res) {
+         /* the whole call is invalid, bail out */
+         softpipe->so_target.num_buffers = 0;
+         draw_set_mapped_so_buffers(softpipe->draw, map_buffers, 0);
+         return;
+      }
+
       softpipe->so_target.buffer[i] = res;
       softpipe->so_target.offset[i] = offsets[i];
       softpipe->so_target.so_count[i] = 0;