From bcfc5f0bdbd4c1eedc22bde5eed464a8bd18211e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 11 May 2007 20:57:12 +0100 Subject: [PATCH] [pixman] Propagate allocation failure. pixman_op() failed to propagate the failure from pixman_region_appendNonO() and the generic op. --- pixman/src/pixregion.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/pixman/src/pixregion.c b/pixman/src/pixregion.c index 9df6611cf..0c214cbc7 100644 --- a/pixman/src/pixregion.c +++ b/pixman/src/pixregion.c @@ -553,7 +553,7 @@ pixman_region_appendNonO ( { \ int newRects; \ if ((newRects = rEnd - r)) { \ - RECTALLOC(newReg, newRects); \ + RECTALLOC_BAIL(newReg, newRects, bail); \ memmove((char *)PIXREGION_TOP(newReg),(char *)r, \ newRects * sizeof(pixman_box16_t)); \ newReg->data->numRects += newRects; \ @@ -733,7 +733,8 @@ pixman_op( bot = MIN(r1->y2, r2y1); if (top != bot) { curBand = newReg->data->numRects; - pixman_region_appendNonO(newReg, r1, r1BandEnd, top, bot); + if (!pixman_region_appendNonO(newReg, r1, r1BandEnd, top, bot)) + goto bail; Coalesce(newReg, prevBand, curBand); } } @@ -744,7 +745,8 @@ pixman_op( bot = MIN(r2->y2, r1y1); if (top != bot) { curBand = newReg->data->numRects; - pixman_region_appendNonO(newReg, r2, r2BandEnd, top, bot); + if (!pixman_region_appendNonO(newReg, r2, r2BandEnd, top, bot)) + goto bail; Coalesce(newReg, prevBand, curBand); } } @@ -760,8 +762,9 @@ pixman_op( ybot = MIN(r1->y2, r2->y2); if (ybot > ytop) { curBand = newReg->data->numRects; - (* overlapFunc)(newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot, - pOverlap); + if (!(* overlapFunc)(newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot, + pOverlap)) + goto bail; Coalesce(newReg, prevBand, curBand); } @@ -786,7 +789,8 @@ pixman_op( /* Do first nonOverlap1Func call, which may be able to coalesce */ FindBand(r1, r1BandEnd, r1End, r1y1); curBand = newReg->data->numRects; - pixman_region_appendNonO(newReg, r1, r1BandEnd, MAX(r1y1, ybot), r1->y2); + if (!pixman_region_appendNonO(newReg, r1, r1BandEnd, MAX(r1y1, ybot), r1->y2)) + goto bail; Coalesce(newReg, prevBand, curBand); /* Just append the rest of the boxes */ AppendRegions(newReg, r1BandEnd, r1End); @@ -795,7 +799,8 @@ pixman_op( /* Do first nonOverlap2Func call, which may be able to coalesce */ FindBand(r2, r2BandEnd, r2End, r2y1); curBand = newReg->data->numRects; - pixman_region_appendNonO(newReg, r2, r2BandEnd, MAX(r2y1, ybot), r2->y2); + if (!pixman_region_appendNonO(newReg, r2, r2BandEnd, MAX(r2y1, ybot), r2->y2)) + goto bail; Coalesce(newReg, prevBand, curBand); /* Append rest of boxes */ AppendRegions(newReg, r2BandEnd, r2End); @@ -821,6 +826,11 @@ pixman_op( } return PIXMAN_REGION_STATUS_SUCCESS; + +bail: + if (oldData) + free(oldData); + return PIXMAN_REGION_STATUS_FAILURE; } /*-