[Bf-blender-cvs] [b1d3b14711b] master: Fix crash when creating an off-screen context fails in Wayland

Campbell Barton noreply at git.blender.org
Fri Jul 1 07:34:28 CEST 2022


Commit: b1d3b14711b2d113742b1693169a0997c737afcc
Author: Campbell Barton
Date:   Fri Jul 1 15:33:18 2022 +1000
Branches: master
https://developer.blender.org/rBb1d3b14711b2d113742b1693169a0997c737afcc

Fix crash when creating an off-screen context fails in Wayland

This is very unlikely to happen but better not to crash.

===================================================================

M	intern/ghost/intern/GHOST_SystemWayland.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index fb34a72235c..3a5e524782f 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -2789,14 +2789,18 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*g
 {
   /* Create new off-screen window. */
   wl_surface *wl_surface = wl_compositor_create_surface(compositor());
-  wl_egl_window *egl_window = wl_egl_window_create(wl_surface, int(1), int(1));
+  wl_egl_window *egl_window = wl_surface ? wl_egl_window_create(wl_surface, 1, 1) : nullptr;
 
   GHOST_Context *context = createOffscreenContext_impl(this, d->display, egl_window);
 
   if (!context) {
     GHOST_PRINT("Cannot create off-screen EGL context" << std::endl);
-    wl_surface_destroy(wl_surface);
-    wl_egl_window_destroy(egl_window);
+    if (wl_surface) {
+      wl_surface_destroy(wl_surface);
+    }
+    if (egl_window) {
+      wl_egl_window_destroy(egl_window);
+    }
     return nullptr;
   }



More information about the Bf-blender-cvs mailing list