From 1a11c0356117fd4e7c5f230b974a9dfd5c8a4dc9 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 20 Dec 2014 13:30:45 +1100 Subject: Don't use bad value after failed call. --- win32/ScintillaWin.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'win32') diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 35c106d5b..5198b0f21 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -485,10 +485,12 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) { ID2D1DCRenderTarget *pDCRT = NULL; HRESULT hr = pD2DFactory->CreateDCRenderTarget(&drtp, &pDCRT); - if (FAILED(hr)) { + if (SUCCEEDED(hr)) { + pRenderTarget = pDCRT; + } else { Platform::DebugPrintf("Failed CreateDCRenderTarget 0x%x\n", hr); + pRenderTarget = NULL; } - pRenderTarget = pDCRT; } else { D2D1_HWND_RENDER_TARGET_PROPERTIES dhrtp; @@ -499,10 +501,12 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) { ID2D1HwndRenderTarget *pHwndRenderTarget = NULL; HRESULT hr = pD2DFactory->CreateHwndRenderTarget(drtp, dhrtp, &pHwndRenderTarget); - if (FAILED(hr)) { + if (SUCCEEDED(hr)) { + pRenderTarget = pHwndRenderTarget; + } else { Platform::DebugPrintf("Failed CreateHwndRenderTarget 0x%x\n", hr); + pRenderTarget = NULL; } - pRenderTarget = pHwndRenderTarget; } #else pD2DFactory->CreateHwndRenderTarget( -- cgit v1.2.3