diff --git a/graphics/ttydrv/palette.c b/graphics/ttydrv/palette.c index 7010775de7e..dc38b5e27ed 100644 --- a/graphics/ttydrv/palette.c +++ b/graphics/ttydrv/palette.c @@ -4,11 +4,12 @@ * Copyright 1999 Patrik Stridvall */ +#include + #include "color.h" #include "debugtools.h" #include "palette.h" #include "ttydrv.h" -#include "xmalloc.h" DEFAULT_DEBUG_CHANNEL(ttydrv) @@ -35,7 +36,11 @@ BOOL TTYDRV_PALETTE_Initialize(void) TTYDRV_DC_DevCaps.sizePalette = 256; - COLOR_sysPal = (PALETTEENTRY *) xmalloc(sizeof(PALETTEENTRY) * TTYDRV_DC_DevCaps.sizePalette); + COLOR_sysPal = (PALETTEENTRY *) HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * TTYDRV_DC_DevCaps.sizePalette); + if(COLOR_sysPal == NULL) { + WARN("No memory to create system palette!"); + return FALSE; + } for(i=0; i < TTYDRV_DC_DevCaps.sizePalette; i++ ) { const PALETTEENTRY *src; diff --git a/graphics/x11drv/bitmap.c b/graphics/x11drv/bitmap.c index 7eefe5471f7..90e2ada0f09 100644 --- a/graphics/x11drv/bitmap.c +++ b/graphics/x11drv/bitmap.c @@ -357,7 +357,13 @@ static LONG X11DRV_SetBitmapBits(BITMAPOBJ *bmp, void *bits, LONG count) EnterCriticalSection( &X11DRV_CritSection ); image = XCreateImage( display, X11DRV_GetVisual(), bmp->bitmap.bmBitsPixel, ZPixmap, 0, NULL, bmp->bitmap.bmWidth, height, 32, 0 ); - image->data = (LPBYTE)xmalloc(image->bytes_per_line * height); + if (!(image->data = (LPBYTE)malloc(image->bytes_per_line * height))) + { + WARN("No memory to create image data.\n"); + XDestroyImage( image ); + LeaveCriticalSection( &X11DRV_CritSection ); + return 0; + } /* copy 16 bit padded image buffer with real bitsperpixel to XImage */ diff --git a/graphics/x11drv/palette.c b/graphics/x11drv/palette.c index f6ae933a44a..7bd0fccdbd6 100644 --- a/graphics/x11drv/palette.c +++ b/graphics/x11drv/palette.c @@ -20,7 +20,6 @@ #include "options.h" #include "palette.h" #include "windef.h" -#include "xmalloc.h" #include "x11drv.h" DEFAULT_DEBUG_CHANNEL(palette); @@ -253,7 +252,10 @@ static BOOL X11DRV_PALETTE_BuildPrivateMap(void) XColor color; int i; - COLOR_sysPal = (PALETTEENTRY*)xmalloc(sizeof(PALETTEENTRY)*X11DRV_DevCaps.sizePalette); + if((COLOR_sysPal = (PALETTEENTRY*)HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY)*X11DRV_DevCaps.sizePalette)) == NULL) { + WARN("Can not allocate system palette\n"); + return FALSE; + } TRACE("Building private map - %i palette entries\n", X11DRV_DevCaps.sizePalette); @@ -402,7 +404,10 @@ static BOOL X11DRV_PALETTE_BuildSharedMap(void) * X guidelines and does binary search... */ - pixDynMapping = (unsigned long*)xmalloc(sizeof(long)*X11DRV_DevCaps.sizePalette); + if((pixDynMapping = (unsigned long*)HeapAlloc(GetProcessHeap(), 0, sizeof(long)*X11DRV_DevCaps.sizePalette)) == NULL) { + WARN("Out of memory while building system palette.\n"); + return FALSE; + } while( c_max - c_min > 0 ) { c_val = (c_max + c_min)/2 + (c_max + c_min)%2; @@ -519,7 +524,7 @@ static BOOL X11DRV_PALETTE_BuildSharedMap(void) X11DRV_PALETTE_XPixelToPalette[X11DRV_PALETTE_PaletteToXPixel[i]] = i; } - if( pixDynMapping ) free(pixDynMapping); + if( pixDynMapping ) HeapFree(GetProcessHeap(), 0, pixDynMapping); return TRUE; }