softpipe: add null ptr check in softpipe_map_constant_buffers()
authorBrian Paul <brianp@vmware.com>
Mon, 9 Feb 2009 17:12:11 +0000 (10:12 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 9 Feb 2009 17:12:11 +0000 (10:12 -0700)
Fixes segfault regression in progs/glsl/identity.c

src/gallium/drivers/softpipe/sp_draw_arrays.c

index ecc9d0031928a6371e0add8a7453ce6b0d864f9c..7e3a25e34b1afa145c0e9c7f873e956f0b80f983 100644 (file)
@@ -47,16 +47,22 @@ static void
 softpipe_map_constant_buffers(struct softpipe_context *sp)
 {
    struct pipe_winsys *ws = sp->pipe.winsys;
-   uint i;
+   uint i, size;
+
    for (i = 0; i < PIPE_SHADER_TYPES; i++) {
       if (sp->constants[i].buffer && sp->constants[i].buffer->size)
          sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i].buffer,
                                                   PIPE_BUFFER_USAGE_CPU_READ);
    }
 
+   if (sp->constants[PIPE_SHADER_VERTEX].buffer)
+      size = sp->constants[PIPE_SHADER_VERTEX].buffer->size;
+   else
+      size = 0;
+
    draw_set_mapped_constant_buffer(sp->draw,
                                    sp->mapped_constants[PIPE_SHADER_VERTEX],
-                                   sp->constants[PIPE_SHADER_VERTEX].buffer->size);
+                                   size);
 }
 
 static void