dri: avoid NULL deref of DrawBuffer on flush

The same problem with 17e62a3c23
fixed for i965 with 6bc710d769
exists with other drivers.

With Mesa 21.3.6 on radeon r100 it shows as:
_mesa_is_winsys_fbo (fb=0x0)
radeonFlush
_mesa_make_current
_mesa_free_context_data
radeonDestroyContext
driDestroyContext
dri2_destroy_context
glx_display_free
__glXCloseDisplay
XCloseDisplay

Follow the i965 change and add a NULL test before flush for
radeon, i915 and nouveau.

Fixes: 17e62a3c23 ("mesa: (correctly) flush more in _mesa_make_current")
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14989>
This commit is contained in:
Jonathan Gray 2022-02-11 14:47:12 +11:00 committed by Eric Engestrom
parent fef2cdb0a5
commit f911daf16d
3 changed files with 5 additions and 3 deletions

View file

@ -111,7 +111,8 @@ intel_flush_front(struct gl_context *ctx)
__DRIdrawable *driDrawable = driContext->driDrawablePriv;
__DRIscreen *const screen = intel->intelScreen->driScrnPriv;
if (intel->front_buffer_dirty && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
if (intel->front_buffer_dirty && ctx->DrawBuffer &&
_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
if (flushFront(screen) &&
driDrawable &&
driDrawable->loaderPrivate) {

View file

@ -71,7 +71,7 @@ nouveau_flush(struct gl_context *ctx, unsigned gallium_flush_flags)
PUSH_KICK(push);
if (_mesa_is_winsys_fbo(ctx->DrawBuffer) &&
if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer) &&
ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
__DRIscreen *screen = nctx->screen->dri_screen;
const __DRIdri2LoaderExtension *dri2 = screen->dri2.loader;

View file

@ -544,7 +544,8 @@ void radeonFlush(struct gl_context *ctx, unsigned gallium_flush_flags)
rcommonFlushCmdBuf(radeon, __func__);
flush_front:
if (_mesa_is_winsys_fbo(ctx->DrawBuffer) && radeon->front_buffer_dirty) {
if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer) &&
radeon->front_buffer_dirty) {
__DRIscreen *const screen = radeon->radeonScreen->driScreen;
if (screen->dri2.loader && (screen->dri2.loader->base.version >= 2)