summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-08-10 11:27:22 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-08-20 12:51:04 -0700
commit5dc8b5385d513bbda88697c2372db750d23f46d4 (patch)
tree2dddb438aea032cbdb55cbad508a163b461079e4 /include
parent453c4ee436ef32d91501d7736d7a91c1aeafc565 (diff)
Avoid memory leak/corruption if realloc fails in Xregion.h:MEMCHECK macro
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'include')
-rw-r--r--include/X11/Xregion.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/X11/Xregion.h b/include/X11/Xregion.h
index c25d70b4..cf10f86d 100644
--- a/include/X11/Xregion.h
+++ b/include/X11/Xregion.h
@@ -112,10 +112,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];\
}\