mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
allocate memory for surfaces on CreateDIBSection failure
This commit is contained in:
parent
0b12de90e2
commit
897fdb5bbb
@ -426,7 +426,7 @@ DWORD WINAPI render_main(void)
|
|||||||
{
|
{
|
||||||
snprintf(
|
snprintf(
|
||||||
debugText, sizeof(debugText),
|
debugText, sizeof(debugText),
|
||||||
"FPS: %lu | Time: %2.2f ms",
|
"FPS: %lu | Time: %2.2f ms ",
|
||||||
frame_count, frameTime);
|
frame_count, frameTime);
|
||||||
|
|
||||||
frame_count = 0;
|
frame_count = 0;
|
||||||
|
@ -51,11 +51,14 @@ ULONG __stdcall ddraw_surface_Release(IDirectDrawSurfaceImpl *This)
|
|||||||
ddraw->primary = NULL;
|
ddraw->primary = NULL;
|
||||||
LeaveCriticalSection(&ddraw->cs);
|
LeaveCriticalSection(&ddraw->cs);
|
||||||
}
|
}
|
||||||
if(This->surface)
|
|
||||||
{
|
if (This->bitmap)
|
||||||
DeleteObject(This->bitmap);
|
DeleteObject(This->bitmap);
|
||||||
|
else if (This->surface)
|
||||||
|
HeapFree(GetProcessHeap(), 0, This->surface);
|
||||||
|
|
||||||
|
if (This->hDC)
|
||||||
DeleteDC(This->hDC);
|
DeleteDC(This->hDC);
|
||||||
}
|
|
||||||
|
|
||||||
if (This->bmi)
|
if (This->bmi)
|
||||||
HeapFree(GetProcessHeap(), 0, This->bmi);
|
HeapFree(GetProcessHeap(), 0, This->bmi);
|
||||||
@ -519,6 +522,10 @@ HRESULT __stdcall ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC lpD
|
|||||||
|
|
||||||
Surface->hDC = CreateCompatibleDC(ddraw->render.hDC);
|
Surface->hDC = CreateCompatibleDC(ddraw->render.hDC);
|
||||||
Surface->bitmap = CreateDIBSection(Surface->hDC, Surface->bmi, DIB_RGB_COLORS, (void **)&Surface->surface, NULL, 0);
|
Surface->bitmap = CreateDIBSection(Surface->hDC, Surface->bmi, DIB_RGB_COLORS, (void **)&Surface->surface, NULL, 0);
|
||||||
|
|
||||||
|
if (!Surface->bitmap)
|
||||||
|
Surface->surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Surface->lPitch * Surface->height * Surface->lXPitch);
|
||||||
|
|
||||||
SelectObject(Surface->hDC, Surface->bitmap);
|
SelectObject(Surface->hDC, Surface->bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user