From be32fbb31b1cf65986b46ed8e837d556546c5e45 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 10 Aug 2013 12:19:17 -0700 Subject: miRegionOp(): ensure region size is not updated if realloc fails This function performs operations on a region, and when finished, checks to see if it should compact the rectangle list. If the number of rectangles for which memory is allocated in the list is more than twice the number used, it tries to shrink. realloc() should not fail in this case, but if it does, might as well keep the correct value for the number of allocated rectangles, so we don't try to grow it unnecessarily later if adding to the region. Signed-off-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/Region.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nx-X11/lib/X11/Region.c b/nx-X11/lib/X11/Region.c index 77e3aed76..3c4263760 100644 --- a/nx-X11/lib/X11/Region.c +++ b/nx-X11/lib/X11/Region.c @@ -980,11 +980,12 @@ miRegionOp( if (REGION_NOT_EMPTY(newReg)) { BoxPtr prev_rects = newReg->rects; - newReg->size = newReg->numRects; newReg->rects = Xrealloc (newReg->rects, - sizeof(BoxRec) * newReg->size); + sizeof(BoxRec) * newReg->numRects); if (! newReg->rects) newReg->rects = prev_rects; + else + newReg->size = newReg->numRects; } else { -- cgit v1.2.3