diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index af3c595..eb29bc5 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -878,8 +878,13 @@ _mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format) GLenum _mesa_get_color_read_format(struct gl_context *ctx) { - const GLenum data_type = _mesa_get_format_datatype( + GLenum data_type; + if (ctx->ReadBuffer != NULL && ctx->ReadBuffer->_ColorReadBuffer != NULL) { + data_type = _mesa_get_format_datatype( ctx->ReadBuffer->_ColorReadBuffer->Format); + } else { + return 0; + } switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { case MESA_FORMAT_ARGB8888: @@ -902,8 +907,13 @@ _mesa_get_color_read_format(struct gl_context *ctx) GLenum _mesa_get_color_read_type(struct gl_context *ctx) { - const GLenum data_type = _mesa_get_format_datatype( - ctx->ReadBuffer->_ColorReadBuffer->Format); + GLenum data_type; + if (ctx->ReadBuffer != NULL && ctx->ReadBuffer->_ColorReadBuffer != NULL) { + data_type = _mesa_get_format_datatype( + ctx->ReadBuffer->_ColorReadBuffer->Format); + } else { + return 0; + } switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { case MESA_FORMAT_RGB565: