aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-08-10 12:19:17 -0700
committerUlrich Sibiller <uli42@gmx.de>2016-10-19 21:40:28 +0200
commitad51fbdb41f8f6bb898ca60b5e547a24aa4ef700 (patch)
tree3204044e5cae4d66741a2ac5e3b39fdc533dbf2b /nx-X11
parent105cd4711219e8f47e21fde03ab2accffbd5d451 (diff)
downloadnx-libs-ad51fbdb41f8f6bb898ca60b5e547a24aa4ef700.tar.gz
nx-libs-ad51fbdb41f8f6bb898ca60b5e547a24aa4ef700.tar.bz2
nx-libs-ad51fbdb41f8f6bb898ca60b5e547a24aa4ef700.zip
miRegionCopy(): handle realloc failure better
Zero out the region size when freeing the region so callers don't think there's anything there. (Pointer is already set to NULL from the realloc result itself.) Return 0 to the callers, and have them cascade that back to their callers to indicate failure, instead of their usual return value of 1 on success. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/lib/X11/Region.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/nx-X11/lib/X11/Region.c b/nx-X11/lib/X11/Region.c
index 998639c25..77e3aed76 100644
--- a/nx-X11/lib/X11/Region.c
+++ b/nx-X11/lib/X11/Region.c
@@ -507,7 +507,7 @@ XIntersectRegion(
return 1;
}
-static void
+static int
miRegionCopy(
register Region dstrgn,
register Region rgn)
@@ -525,7 +525,8 @@ miRegionCopy(
rgn->numRects * (sizeof(BOX)));
if (! dstrgn->rects) {
Xfree(prevRects);
- return;
+ dstrgn->size = 0;
+ return 0;
}
}
dstrgn->size = rgn->numRects;
@@ -539,6 +540,7 @@ miRegionCopy(
memcpy((char *) dstrgn->rects, (char *) rgn->rects,
(int) (rgn->numRects * sizeof(BOX)));
}
+ return 1;
}
/*======================================================================
@@ -1150,7 +1152,7 @@ XUnionRegion(
if ( (reg1 == reg2) || (!(reg1->numRects)) )
{
if (newReg != reg2)
- miRegionCopy(newReg, reg2);
+ return miRegionCopy(newReg, reg2);
return 1;
}
@@ -1160,7 +1162,7 @@ XUnionRegion(
if (!(reg2->numRects))
{
if (newReg != reg1)
- miRegionCopy(newReg, reg1);
+ return miRegionCopy(newReg, reg1);
return 1;
}
@@ -1174,7 +1176,7 @@ XUnionRegion(
(reg1->extents.y2 >= reg2->extents.y2))
{
if (newReg != reg1)
- miRegionCopy(newReg, reg1);
+ return miRegionCopy(newReg, reg1);
return 1;
}
@@ -1188,7 +1190,7 @@ XUnionRegion(
(reg2->extents.y2 >= reg1->extents.y2))
{
if (newReg != reg2)
- miRegionCopy(newReg, reg2);
+ return miRegionCopy(newReg, reg2);
return 1;
}
@@ -1429,8 +1431,7 @@ XSubtractRegion(
if ( (!(regM->numRects)) || (!(regS->numRects)) ||
(!EXTENTCHECK(&regM->extents, &regS->extents)) )
{
- miRegionCopy(regD, regM);
- return 1;
+ return miRegionCopy(regD, regM);
}
miRegionOp (regD, regM, regS, miSubtractO,