st/mesa: fix crash when DrawBuffer->_ColorDrawBuffers[0] is NULL
authorMarek Olšák <maraeo@gmail.com>
Sun, 20 Feb 2011 15:50:48 +0000 (16:50 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sun, 20 Feb 2011 21:16:22 +0000 (22:16 +0100)
This fixes the game Tiny and Big.

src/mesa/state_tracker/st_cb_clear.c

index d81e554b294f873c4002a2981ad2a89210c03303..0e0c4326ed711e4676df575c38e1f16c399755d3 100644 (file)
@@ -300,9 +300,11 @@ clear_with_quad(struct gl_context *ctx,
    cso_set_fragment_shader_handle(st->cso_context, st->clear.fs);
    cso_set_vertex_shader_handle(st->cso_context, st->clear.vs);
 
-   st_translate_color(ctx->Color.ClearColor,
-                      ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
-                      clearColor);
+   if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
+      st_translate_color(ctx->Color.ClearColor,
+                         ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
+                         clearColor);
+   }
 
    /* draw quad matching scissor rect */
    draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, clearColor);
@@ -555,9 +557,11 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
            ctx->DrawBuffer->Visual.stencilBits == 0))
          clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL;
 
-      st_translate_color(ctx->Color.ClearColor,
-                         ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
-                         clearColor);
+      if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
+         st_translate_color(ctx->Color.ClearColor,
+                            ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
+                            clearColor);
+      }
 
       st->pipe->clear(st->pipe, clear_buffers, ctx->Color.ClearColor,
                       ctx->Depth.Clear, ctx->Stencil.Clear);