[Bf-blender-cvs] [ff651a08b50] master: Fix returning a freed context when initialization fails for GHOST/Win32

Campbell Barton noreply at git.blender.org
Wed Aug 31 07:05:22 CEST 2022


Commit: ff651a08b50cade1adf6e4d7a810500c88eb1987
Author: Campbell Barton
Date:   Wed Aug 31 14:26:58 2022 +1000
Branches: master
https://developer.blender.org/rBff651a08b50cade1adf6e4d7a810500c88eb1987

Fix returning a freed context when initialization fails for GHOST/Win32

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

M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_WindowWin32.cpp

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

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index c03d468160a..b583d39dd1f 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -353,6 +353,7 @@ GHOST_ContextD3D *GHOST_SystemWin32::createOffscreenContextD3D()
   context = new GHOST_ContextD3D(false, wnd);
   if (context->initializeDrawingContext() == GHOST_kFailure) {
     delete context;
+    context = nullptr;
   }
 
   return context;
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 4d8e0d492d9..50ee9385e39 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -624,11 +624,9 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
     GHOST_Context *context;
 
     context = new GHOST_ContextD3D(false, m_hWnd);
-    if (context->initializeDrawingContext()) {
-      return context;
-    }
-    else {
+    if (!context->initializeDrawingContext()) {
       delete context;
+      context = nullptr;
     }
 
     return context;



More information about the Bf-blender-cvs mailing list