Set _ColorDrawBuffers[0] = NULL if no renderbuffers enabled.
Check that _ColorDrawBuffers[0] is non-null before dereferencing in a few places.
{
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
- struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb->Wrapped);
+ struct xmesa_renderbuffer *xrb;
+
+ if (!rb)
+ return;
+
+ xrb = xmesa_renderbuffer(rb->Wrapped);
if (swrast->NewState)
_swrast_validate_derived( ctx );
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels )
{
- struct xmesa_renderbuffer *xrb
- = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
const XMesaGC gc = xmbuf->cleargc; /* effected by glColorMask */
+ struct xmesa_renderbuffer *xrb;
ASSERT(dpy);
ASSERT(gc);
ASSERT(xmesa->xm_visual->undithered_pf == PF_5R6G5B);
+ if (!ctx->DrawBuffer->_ColorDrawBuffers[0])
+ return;
+
+ xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
+
if (swrast->NewState)
_swrast_validate_derived( ctx );
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
const XMesaGC gc = xmbuf->cleargc; /* effected by glColorMask */
- struct xmesa_renderbuffer *srcXrb
- = xmesa_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer->Wrapped);
- struct xmesa_renderbuffer *dstXrb
- = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
+ struct xmesa_renderbuffer *srcXrb, *dstXrb;
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer ||
+ !ctx->DrawBuffer->_ColorDrawBuffers[0])
+ return;
ASSERT(dpy);
ASSERT(gc);
+ srcXrb = xmesa_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer->Wrapped);
+ dstXrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
+
if (swrast->NewState)
_swrast_validate_derived( ctx );
{
GLuint output;
+ /* set 0th buffer to NULL now in case _NumColorDrawBuffers is zero */
+ fb->_ColorDrawBuffers[0] = NULL;
+
for (output = 0; output < fb->_NumColorDrawBuffers; output++) {
GLint buf = fb->_ColorDrawBufferIndexes[output];
if (buf >= 0) {
};
GLint i;
+ if (!ctx->DrawBuffer->_NumColorDrawBuffers)
+ return;
+
if (!clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1,
&dstX0, &dstY0, &dstX1, &dstY1)) {
return;
{
const GLint imgX = x, imgY = y;
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
- const GLenum rbType = rb->DataType;
+ GLenum rbType;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
SWspan span;
GLboolean simpleZoom;
struct gl_pixelstore_attrib unpack;
GLint destX, destY, drawWidth, drawHeight; /* post clipping */
+ if (!rb)
+ return GL_TRUE; /* no-op */
+
+ rbType = rb->DataType;
+
if ((swrast->_RasterMask & ~CLIP_BIT) ||
ctx->Texture._EnabledCoordUnits ||
userUnpack->SwapBytes ||
#define T_SCALE theight
#define SETUP_CODE \
- struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];\
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \
struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
const GLint b = obj->BaseLevel; \
const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \
const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data; \
const GLint smask = obj->Image[0][b]->Width - 1; \
const GLint tmask = obj->Image[0][b]->Height - 1; \
- if (!texture) { \
- /* this shouldn't happen */ \
+ if (!rb || !texture) { \
return; \
}
#define T_SCALE theight
#define SETUP_CODE \
- struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];\
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \
struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
const GLint b = obj->BaseLevel; \
const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \
const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data; \
const GLint smask = obj->Image[0][b]->Width - 1; \
const GLint tmask = obj->Image[0][b]->Height - 1; \
- if (!texture) { \
- /* this shouldn't happen */ \
+ if (!rb || !texture) { \
return; \
}