diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-08-10 12:19:17 -0700 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2016-10-19 21:40:28 +0200 |
commit | be32fbb31b1cf65986b46ed8e837d556546c5e45 (patch) | |
tree | 9ba91af29005b0fb4e0b52adb3b0ec0f23a87515 /nx-X11/lib/X11 | |
parent | ad51fbdb41f8f6bb898ca60b5e547a24aa4ef700 (diff) | |
download | nx-libs-be32fbb31b1cf65986b46ed8e837d556546c5e45.tar.gz nx-libs-be32fbb31b1cf65986b46ed8e837d556546c5e45.tar.bz2 nx-libs-be32fbb31b1cf65986b46ed8e837d556546c5e45.zip |
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 <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/Region.c | 5 |
1 files 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 { |