From 7a0f7f739804bc7d9c5562701abee8d134878977 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 9 Mar 2006 23:29:44 +0000 Subject: [PATCH] Coverity #349: Fall back to software early if pSrc->pDrawable is NULL, or pMask is non-NULL but pMask->pDrawable is NULL. This prevents NULL dereferences on gradients and other Pictures which have no pDrawable. --- ChangeLog | 7 +++++++ exa/exa_render.c | 17 ++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f9d695a4..c08dc40f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-09 Eric Anholt + + * exa/exa_render.c: (exaComposite): + Coverity #349: Fall back to software early if pSrc->pDrawable is NULL, + or pMask is non-NULL but pMask->pDrawable is NULL. This prevents NULL + dereferences on gradients and other Pictures which have no pDrawable. + 2006-03-09 Eric Anholt * exa/exa.c: diff --git a/exa/exa_render.c b/exa/exa_render.c index f45f08916..e0d9fda16 100644 --- a/exa/exa_render.c +++ b/exa/exa_render.c @@ -449,10 +449,14 @@ exaComposite(CARD8 op, Bool saveSrcRepeat = pSrc->repeat; Bool saveMaskRepeat = pMask ? pMask->repeat : 0; - if (pExaScr->swappedOut) { - exaDrawableDirty(pDst->pDrawable); - pExaScr->SavedComposite(op, pSrc, pMask, pDst, xSrc, ySrc, - xMask, yMask, xDst, yDst, width, height); + /* We currently don't support acceleration of gradients, or other pictures + * with a NULL pDrawable. + */ + if (pExaScr->swappedOut || + pSrc->pDrawable == NULL || (pMask != NULL && pMask->pDrawable == NULL)) + { + ExaCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height); return; } @@ -462,7 +466,7 @@ exaComposite(CARD8 op, (ySrc + height) <= pSrc->pDrawable->height) pSrc->repeat = 0; - if (!pMask && pSrc->pDrawable) + if (!pMask) { if (op == PictOpSrc) { @@ -507,8 +511,7 @@ exaComposite(CARD8 op, pMask->repeat = 0; - if (pSrc->pDrawable && (!pMask || pMask->pDrawable) && - pExaScr->info->PrepareComposite && + if (pExaScr->info->PrepareComposite && !pSrc->alphaMap && (!pMask || !pMask->alphaMap) && !pDst->alphaMap) { ret = exaTryDriverComposite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask,