From f50bb771c9cb4f63031d5a2ec873947359430fa5 Mon Sep 17 00:00:00 2001 From: Christian Costa Date: Wed, 16 Aug 2006 22:35:58 +0200 Subject: [PATCH] wined3d: Make sure b_info structure is properly allocated and released. --- dlls/wined3d/surface.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index f7b73b65046..0e0e6dd0468 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1269,6 +1269,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) { break; } + if (!b_info) + return E_OUTOFMEMORY; + /* Some apps access the surface in via DWORDs, and do not take the necessary care at the end of the * surface. So we need at least extra 4 bytes at the end of the surface. Check against the page size, * if the last page used for the surface has at least 4 spare bytes we're safe, otherwise @@ -1347,9 +1350,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) { if (!This->dib.DIBsection) { ERR("CreateDIBSection failed!\n"); + HeapFree(GetProcessHeap(), 0, b_info); return HRESULT_FROM_WIN32(GetLastError()); } - HeapFree(GetProcessHeap(), 0, b_info); TRACE("DIBSection at : %p\n", This->dib.bitmap_data); @@ -1363,6 +1366,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) { This->Flags |= SFLAG_GLDIRTY; } + HeapFree(GetProcessHeap(), 0, b_info); + /* Use the dib section from now on */ This->resource.allocatedMemory = This->dib.bitmap_data;