wined3d: Make sure b_info structure is properly allocated and released.

This commit is contained in:
Christian Costa 2006-08-16 22:35:58 +02:00 committed by Alexandre Julliard
parent 8904529dda
commit f50bb771c9
1 changed files with 6 additions and 1 deletions

View File

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