aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-08-10 11:27:22 -0700
committerUlrich Sibiller <uli42@gmx.de>2016-10-19 21:40:28 +0200
commit105cd4711219e8f47e21fde03ab2accffbd5d451 (patch)
treef1a9ac8fc9c14fd4ad5b423728795b34303f31ad /nx-X11/lib/X11
parent180991ce21c79c9a2816a5cbddc5232555fc954c (diff)
downloadnx-libs-105cd4711219e8f47e21fde03ab2accffbd5d451.tar.gz
nx-libs-105cd4711219e8f47e21fde03ab2accffbd5d451.tar.bz2
nx-libs-105cd4711219e8f47e21fde03ab2accffbd5d451.zip
Avoid memory leak/corruption if realloc fails in Xregion.h:MEMCHECK macro
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib/X11')
-rw-r--r--nx-X11/lib/X11/Xregion.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/nx-X11/lib/X11/Xregion.h b/nx-X11/lib/X11/Xregion.h
index 1c36db144..4f55af82f 100644
--- a/nx-X11/lib/X11/Xregion.h
+++ b/nx-X11/lib/X11/Xregion.h
@@ -113,10 +113,11 @@ typedef struct _XRegion {
*/
#define MEMCHECK(reg, rect, firstrect){\
if ((reg)->numRects >= ((reg)->size - 1)){\
- (firstrect) = (BOX *) Xrealloc \
- ((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\
- if ((firstrect) == 0)\
+ BoxPtr tmpRect = Xrealloc ((firstrect), \
+ (2 * (sizeof(BOX)) * ((reg)->size))); \
+ if (tmpRect == NULL) \
return(0);\
+ (firstrect) = tmpRect; \
(reg)->size *= 2;\
(rect) = &(firstrect)[(reg)->numRects];\
}\