font_windows.c: don't crash if no memory for bitmap [Peter Ferrie]

more graceful exit will occur when next malloc() fails, and condition
might be temporary
This commit is contained in:
Peter Ferrie 2015-03-18 19:18:00 -07:00
parent 490ed5ce9b
commit 9cf8308096

View File

@ -169,6 +169,9 @@ bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT
// create a DIB to render to
BYTE *bits;
HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits), NULL, 0);
if (dib)
{
HGDIOBJ oldbitmap = SelectObject(dummyDC, dib);
// clear the bitmap
@ -253,6 +256,8 @@ bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT
// de-select the font and release the DC
SelectObject(dummyDC, oldbitmap);
DeleteObject(dib);
}
SelectObject(dummyDC, oldfont);
DeleteDC(dummyDC);
return bitmap.valid();