From: Tim Waugh Date: Wed, 25 Feb 2015 12:25:33 +0000 (+0000) Subject: Check for out-of-memory when installing color map. X-Git-Tag: v1.4.90~37^2~2^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F134%2Fhead;p=tigervnc.git Check for out-of-memory when installing color map. Also remove Xalloc/Xfree definitions, using malloc/free directly instead. Note that vfbAllocateFramebufferMemory() does not need to check for failed allocations as it is the caller's responsibility to do so (and they do). --- diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c index 042c0a49..80198958 100644 --- a/unix/xserver/hw/vnc/xvnc.c +++ b/unix/xserver/hw/vnc/xvnc.c @@ -87,11 +87,6 @@ from the X Consortium. #endif #include "site.h" -#if XORG >= 110 -#define Xalloc malloc -#define Xfree free -#endif - #define XVNCVERSION "TigerVNC 1.4.80" #define XVNCCOPYRIGHT ("Copyright (C) 1999-2015 TigerVNC Team and many others (see README.txt)\n" \ "See http://www.tigervnc.org for information on TigerVNC.\n") @@ -682,6 +677,8 @@ vfbInstallColormap(ColormapPtr pmap) ppix = (Pixel *)calloc(entries, sizeof(Pixel)); prgb = (xrgb *)calloc(entries, sizeof(xrgb)); defs = (xColorItem *)calloc(entries, sizeof(xColorItem)); + if (!ppix || !prgb || !defs) + FatalError ("Not enough memory for color map\n"); for (i = 0; i < entries; i++) ppix[i] = i; /* XXX truecolor */ @@ -786,7 +783,7 @@ vfbAllocateFramebufferMemory(vfbFramebufferInfoPtr pfb) break; #endif case NORMAL_MEMORY_FB: - pfb->pfbMemory = Xalloc(pfb->sizeInBytes); + pfb->pfbMemory = malloc(pfb->sizeInBytes); break; } @@ -813,7 +810,7 @@ vfbFreeFramebufferMemory(vfbFramebufferInfoPtr pfb) break; #endif /* HAS_SHM */ case NORMAL_MEMORY_FB: - Xfree(pfb->pfbMemory); + free(pfb->pfbMemory); break; }