diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-12-13 19:44:15 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-12-14 10:35:04 +0000 |
commit | 4f1a99a70e76ea5637c5ee8226b2e52a464f5948 (patch) | |
tree | 63f271b593ce069c23307e5816052c181c773045 /src/sna/sna_composite.c | |
parent | d2c6d950ed2c5882e7d501b6974e72be4d6da8a8 (diff) |
sna: Protect against deferred malloc failures for pixel data
As we now defer the allocation of pixel data until first use, it can
fail in the middle of a rendering routine. In order to prevent chasing
us passing a NULL pointer into the fallback routines, we need to propagate
the failure from the malloc and suppress the failure, discarding the
operation, which is less than ideal.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_composite.c')
-rw-r--r-- | src/sna/sna_composite.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c index 3c04d323..09d38276 100644 --- a/src/sna/sna_composite.c +++ b/src/sna/sna_composite.c @@ -478,8 +478,7 @@ sna_composite(CARD8 op, apply_damage(&tmp, ®ion); tmp.done(sna, &tmp); - REGION_UNINIT(NULL, ®ion); - return; + goto out; fallback: DBG(("%s -- fallback dst=(%d, %d)+(%d, %d), size=(%d, %d)\n", @@ -488,18 +487,24 @@ fallback: dst->pDrawable->x, dst->pDrawable->y, width, height)); - sna_drawable_move_region_to_cpu(dst->pDrawable, ®ion, true); - if (dst->alphaMap) - sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true); + if (!sna_drawable_move_region_to_cpu(dst->pDrawable, ®ion, true)) + goto out; + if (dst->alphaMap && + !sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true)) + goto out; if (src->pDrawable) { - sna_drawable_move_to_cpu(src->pDrawable, false); - if (src->alphaMap) - sna_drawable_move_to_cpu(src->alphaMap->pDrawable, false); + if (!sna_drawable_move_to_cpu(src->pDrawable, false)) + goto out; + if (src->alphaMap && + !sna_drawable_move_to_cpu(src->alphaMap->pDrawable, false)) + goto out; } if (mask && mask->pDrawable) { - sna_drawable_move_to_cpu(mask->pDrawable, false); - if (mask->alphaMap) - sna_drawable_move_to_cpu(mask->alphaMap->pDrawable, false); + if (!sna_drawable_move_to_cpu(mask->pDrawable, false)) + goto out; + if (mask->alphaMap && + !sna_drawable_move_to_cpu(mask->alphaMap->pDrawable, false)) + goto out; } DBG(("%s: fallback -- fbComposite\n", __FUNCTION__)); @@ -508,6 +513,8 @@ fallback: mask_x, mask_y, dst_x, dst_y, width, height); +out: + REGION_UNINIT(NULL, ®ion); } static int16_t bound(int16_t a, uint16_t b) @@ -732,9 +739,11 @@ sna_composite_rectangles(CARD8 op, fallback: DBG(("%s: fallback\n", __FUNCTION__)); - sna_drawable_move_region_to_cpu(&pixmap->drawable, ®ion, true); - if (dst->alphaMap) - sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true); + if (!sna_drawable_move_region_to_cpu(&pixmap->drawable, ®ion, true)) + goto done; + if (dst->alphaMap && + !sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true)) + goto done; if (op == PictOpSrc || op == PictOpClear) { int nbox = REGION_NUM_RECTS(®ion); |