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.
This commit is contained in:
Eric Anholt 2006-03-09 23:29:44 +00:00
parent 8a3ff42abb
commit 7a0f7f7398
2 changed files with 17 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2006-03-09 Eric Anholt <anholt@FreeBSD.org>
* 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 <anholt@FreeBSD.org> 2006-03-09 Eric Anholt <anholt@FreeBSD.org>
* exa/exa.c: * exa/exa.c:

View File

@ -449,10 +449,14 @@ exaComposite(CARD8 op,
Bool saveSrcRepeat = pSrc->repeat; Bool saveSrcRepeat = pSrc->repeat;
Bool saveMaskRepeat = pMask ? pMask->repeat : 0; Bool saveMaskRepeat = pMask ? pMask->repeat : 0;
if (pExaScr->swappedOut) { /* We currently don't support acceleration of gradients, or other pictures
exaDrawableDirty(pDst->pDrawable); * with a NULL pDrawable.
pExaScr->SavedComposite(op, pSrc, pMask, pDst, xSrc, ySrc, */
xMask, yMask, xDst, yDst, width, height); 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; return;
} }
@ -462,7 +466,7 @@ exaComposite(CARD8 op,
(ySrc + height) <= pSrc->pDrawable->height) (ySrc + height) <= pSrc->pDrawable->height)
pSrc->repeat = 0; pSrc->repeat = 0;
if (!pMask && pSrc->pDrawable) if (!pMask)
{ {
if (op == PictOpSrc) if (op == PictOpSrc)
{ {
@ -507,8 +511,7 @@ exaComposite(CARD8 op,
pMask->repeat = 0; pMask->repeat = 0;
if (pSrc->pDrawable && (!pMask || pMask->pDrawable) && if (pExaScr->info->PrepareComposite &&
pExaScr->info->PrepareComposite &&
!pSrc->alphaMap && (!pMask || !pMask->alphaMap) && !pDst->alphaMap) !pSrc->alphaMap && (!pMask || !pMask->alphaMap) && !pDst->alphaMap)
{ {
ret = exaTryDriverComposite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, ret = exaTryDriverComposite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask,