aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Waugh <twaugh@redhat.com>2015-02-25 12:25:33 +0000
committerTim Waugh <twaugh@redhat.com>2015-02-25 17:19:45 +0000
commit897fc0ae9d80606b26f00c036732d9c5547d112b (patch)
treeb338f86f88c11fc6e0aed1db6bdc3df3189ee806
parent242fdf0c5a5483910537419a4833c3f725889095 (diff)
downloadtigervnc-897fc0ae9d80606b26f00c036732d9c5547d112b.tar.gz
tigervnc-897fc0ae9d80606b26f00c036732d9c5547d112b.zip
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).
-rw-r--r--unix/xserver/hw/vnc/xvnc.c11
1 files changed, 4 insertions, 7 deletions
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;
}