[PATCH] xserver: Don't crash if Xv is not initialized
Mauro Carvalho Chehab
mchehab at infradead.org
Mon Feb 14 16:43:57 PST 2011
The xf86-video-v4l video driver calls xf86XVQueryOffscreenImages()
function in order to probe for the Xv FOURCC formats supported for
PutVideo ops. However, as this support is deprecated on most of
the modern drivers, a call to this method will cause a crash:
X: ../../../include/privates.h:115: dixGetPrivateAddr: Assertion `key->initialized' failed.
The reason is that this function calls dixGetPrivate in order to
locate the map. At include/privates.h, this is declared as:
static inline void *
dixGetPrivateAddr(PrivatePtr *privates, const DevPrivateKey key)
{
assert(key->initialized);
return (char *) (*privates) + key->offset;
}
As nobody registered it, key->initialized is FALSE, and assert will
complain, causing the crash.
More information is available on this bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=675532
Reviewed-by: Dave Airlie <airlied at redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab at redhat.com>
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 016db1f..858d3bc 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -218,7 +218,14 @@ xf86XVQueryOffscreenImages(
ScreenPtr pScreen,
int *num
){
- OffscreenImageRec *OffscreenImage = GetOffscreenImage(pScreen);
+ OffscreenImageRec *OffscreenImage;
+
+ if (!OffscreenPrivateKey->initialized) {
+ *num = 0;
+ return NULL;
+ }
+
+ OffscreenImage = GetOffscreenImage(pScreen);
*num = OffscreenImage->num;
return OffscreenImage->images;
}
More information about the xorg-devel
mailing list