Don't unwrap too early in libwfb for Composite.

Don't call fbFinishWrap until the pixman_image_t that stores the pointer is
actually freed.  This prevents corruption or crashes caused by accessing a
wrapped pointer after the wrapping is torn down.
This commit is contained in:
Aaron Plattner 2007-08-01 14:30:03 -07:00
parent f6aa2200f2
commit 74feba4d77
4 changed files with 16 additions and 17 deletions

View File

@ -2117,6 +2117,7 @@ fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
pixman_image_t *image_from_pict (PicturePtr pict, pixman_image_t *image_from_pict (PicturePtr pict,
Bool has_clip); Bool has_clip);
void free_pixman_pict (PicturePtr, pixman_image_t *);
#endif /* _FB_H_ */ #endif /* _FB_H_ */

View File

@ -185,15 +185,11 @@ fbComposite (CARD8 op,
pixman_image_composite (op, src, mask, dest, pixman_image_composite (op, src, mask, dest,
xSrc, ySrc, xMask, yMask, xDst, yDst, xSrc, ySrc, xMask, yMask, xDst, yDst,
width, height); width, height);
} }
if (src) free_pixman_pict (pSrc, src);
pixman_image_unref (src); free_pixman_pict (pMask, mask);
if (mask) free_pixman_pict (pDst, dest);
pixman_image_unref (mask);
if (dest)
pixman_image_unref (dest);
} }
void void
@ -333,8 +329,6 @@ create_bits_picture (PicturePtr pict,
if (pict->pFormat->index.devPrivate) if (pict->pFormat->index.devPrivate)
pixman_image_set_indexed (image, pict->pFormat->index.devPrivate); pixman_image_set_indexed (image, pict->pFormat->index.devPrivate);
fbFinishAccess (pict->pDrawable);
return image; return image;
} }
@ -379,7 +373,7 @@ set_image_properties (pixman_image_t *image, PicturePtr pict)
pixman_image_set_alpha_map ( pixman_image_set_alpha_map (
image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y); image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
pixman_image_unref (alpha_map); free_pixman_pict (pict->alphaMap, alpha_map);
} }
pixman_image_set_component_alpha (image, pict->componentAlpha); pixman_image_set_component_alpha (image, pict->componentAlpha);
@ -445,6 +439,13 @@ image_from_pict (PicturePtr pict,
return image; return image;
} }
void
free_pixman_pict (PicturePtr pict, pixman_image_t *image)
{
if (image && pixman_image_unref (image) && pict->pDrawable)
fbFinishAccess (pict->pDrawable);
}
Bool Bool
fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
{ {

View File

@ -47,9 +47,7 @@ fbAddTraps (PicturePtr pPicture,
pixman_add_traps (image, x_off, y_off, ntrap, (pixman_trap_t *)traps); pixman_add_traps (image, x_off, y_off, ntrap, (pixman_trap_t *)traps);
fbFinishAccess (pPicture->pDrawable); free_pixman_pict (pPicture, image);
pixman_image_unref (image);
} }
void void
@ -65,9 +63,7 @@ fbRasterizeTrapezoid (PicturePtr pPicture,
pixman_rasterize_trapezoid (image, (pixman_trapezoid_t *)trap, x_off, y_off); pixman_rasterize_trapezoid (image, (pixman_trapezoid_t *)trap, x_off, y_off);
fbFinishAccess (pPicture->pDrawable); free_pixman_pict (pPicture, image);
pixman_image_unref (image);
} }
static int static int

View File

@ -188,6 +188,7 @@
#define fbWinPrivateIndex wfbWinPrivateIndex #define fbWinPrivateIndex wfbWinPrivateIndex
#define fbZeroLine wfbZeroLine #define fbZeroLine wfbZeroLine
#define fbZeroSegment wfbZeroSegment #define fbZeroSegment wfbZeroSegment
#define free_pixman_pict wfb_free_pixman_pict
#define image_from_pict wfb_image_from_pict #define image_from_pict wfb_image_from_pict
#define xxScrPrivateIndex wfbxxScrPrivateIndex #define xxScrPrivateIndex wfbxxScrPrivateIndex
#define xxGCPrivateIndex wfbxxGCPrivateIndex #define xxGCPrivateIndex wfbxxGCPrivateIndex