mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-01-03 22:10:12 +01:00
Avoid memory leak/corruption if realloc fails in Xregion.h:MEMCHECK macro
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
parent
453c4ee436
commit
5dc8b5385d
1 changed files with 4 additions and 3 deletions
|
|
@ -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];\
|
||||
}\
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue