From a2751080aad2b061d8a2954c9144ed86fe1bba8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Tue, 8 Dec 2020 22:57:39 -0500 Subject: [PATCH] wgl: Don't crash in stw_make_current if current framebuffer is NULL MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes #3878 Signed-off-by: Louis-Francis Ratté-Boulianne Part-of: --- src/gallium/frontends/wgl/stw_context.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gallium/frontends/wgl/stw_context.c b/src/gallium/frontends/wgl/stw_context.c index 91861cd..8f7150e 100644 --- a/src/gallium/frontends/wgl/stw_context.c +++ b/src/gallium/frontends/wgl/stw_context.c @@ -446,11 +446,21 @@ stw_make_current(HDC hDrawDC, HDC hReadDC, DHGLRC dhglrc) } } else { if (old_ctx->shared) { - stw_st_flush(old_ctx->st, old_ctx->current_framebuffer->stfb, - ST_FLUSH_FRONT | ST_FLUSH_WAIT); + if (old_ctx->current_framebuffer) { + stw_st_flush(old_ctx->st, old_ctx->current_framebuffer->stfb, + ST_FLUSH_FRONT | ST_FLUSH_WAIT); + } else { + struct pipe_fence_handle *fence = NULL; + old_ctx->st->flush(old_ctx->st, + ST_FLUSH_FRONT | ST_FLUSH_WAIT, &fence, + NULL, NULL); + } } else { - stw_st_flush(old_ctx->st, old_ctx->current_framebuffer->stfb, - ST_FLUSH_FRONT); + if (old_ctx->current_framebuffer) + stw_st_flush(old_ctx->st, old_ctx->current_framebuffer->stfb, + ST_FLUSH_FRONT); + else + old_ctx->st->flush(old_ctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL); } } } -- 2.7.4