Commit 8226a187 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dx9: Don't call CoUninitialize if CoInitializeEx failed.

parent 244100f0
...@@ -1025,7 +1025,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface, ...@@ -1025,7 +1025,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
const RECT *pSrcRect, DWORD dwFilter, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo) const RECT *pSrcRect, DWORD dwFilter, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo)
{ {
D3DXIMAGE_INFO imginfo; D3DXIMAGE_INFO imginfo;
HRESULT hr; HRESULT hr, com_init;
IWICImagingFactory *factory = NULL; IWICImagingFactory *factory = NULL;
IWICBitmapDecoder *decoder; IWICBitmapDecoder *decoder;
...@@ -1078,7 +1078,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface, ...@@ -1078,7 +1078,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
if (imginfo.ImageFileFormat == D3DXIFF_DIB) if (imginfo.ImageFileFormat == D3DXIFF_DIB)
convert_dib_to_bmp((void**)&pSrcData, &SrcDataSize); convert_dib_to_bmp((void**)&pSrcData, &SrcDataSize);
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); com_init = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&factory))) if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&factory)))
goto cleanup_err; goto cleanup_err;
...@@ -1181,7 +1181,8 @@ cleanup_err: ...@@ -1181,7 +1181,8 @@ cleanup_err:
if (factory) if (factory)
IWICImagingFactory_Release(factory); IWICImagingFactory_Release(factory);
CoUninitialize(); if (SUCCEEDED(com_init))
CoUninitialize();
if (imginfo.ImageFileFormat == D3DXIFF_DIB) if (imginfo.ImageFileFormat == D3DXIFF_DIB)
HeapFree(GetProcessHeap(), 0, (void*)pSrcData); HeapFree(GetProcessHeap(), 0, (void*)pSrcData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment