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

This commit is contained in:
Campbell Barton 2022-08-31 14:26:58 +10:00
parent 4df3cf020b
commit ff651a08b5
2 changed files with 3 additions and 4 deletions

View File

@ -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;

View File

@ -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;