Module: Mesa
Branch: master
Commit: a2751080aad2b061d8a2954c9144ed86fe1bba8d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a2751080aad2b061d8a2954c9144ed86fe1bba8d

Author: Louis-Francis Ratté-Boulianne <l...@collabora.com>
Date:   Tue Dec  8 22:57:39 2020 -0500

wgl: Don't crash in stw_make_current if current framebuffer is NULL

Fixes #3878

Signed-off-by: Louis-Francis Ratté-Boulianne <l...@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7999>

---

 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 91861cd42e9..8f7150eb6df 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);
          }
       }
    }

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to