Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-08-31 07:26:58 +0300
committerCampbell Barton <campbell@blender.org>2022-08-31 07:55:47 +0300
commitff651a08b50cade1adf6e4d7a810500c88eb1987 (patch)
tree7b14f192382521fd9a30c825b833404660d99e3e
parent4df3cf020bd0038f5533382989a05f4e4f76a111 (diff)
Fix returning a freed context when initialization fails for GHOST/Win32
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp1
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp6
2 files changed, 3 insertions, 4 deletions
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;