swrast: check for null/-1 when mapping renderbuffers
authorBrian Paul <brianp@vmware.com>
Mon, 20 Jan 2014 16:06:35 +0000 (08:06 -0800)
committerBrian Paul <brianp@vmware.com>
Mon, 20 Jan 2014 16:18:21 +0000 (08:18 -0800)
Fixes fbo-drawbuffers-none crash (but test still fails).
https://bugs.freedesktop.org/show_bug.cgi?id=73757

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/mesa/swrast/s_renderbuffer.c

index e3f33de7dc6899e0a25a892e4c50b231dd94d37d..a19d02ac0cdfe3115e37609f9dd2d38ff93be351 100644 (file)
@@ -659,8 +659,10 @@ _swrast_map_renderbuffers(struct gl_context *ctx)
    }
 
    for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) {
-      map_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]);
-      find_renderbuffer_colortype(fb->_ColorDrawBuffers[buf]);
+      if (fb->_ColorDrawBufferIndexes[buf] >= 0) {
+         map_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]);
+         find_renderbuffer_colortype(fb->_ColorDrawBuffers[buf]);
+      }
    }
 }
  
@@ -688,6 +690,8 @@ _swrast_unmap_renderbuffers(struct gl_context *ctx)
    }
 
    for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) {
-      unmap_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]);
+      if (fb->_ColorDrawBufferIndexes[buf] >= 0) {
+         unmap_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]);
+      }
    }
 }