[Libva] vaDisplayIsValid w/t magic number
Yuan, Shengquan
shengquan.yuan at gmail.com
Fri Nov 20 02:08:36 PST 2009
There is a VA test case which passes an illegal va_dpy, e.g.
vaMaxNumConfigAttributes(0x34534). vaDisplayIsValid check whether
va_dpy==NULL, if not then call dpy->vaIsValid, and it will get a
SEGFAULT
We can avoid it with a stupid magic number, then every backend need
use the same magic number:
diff --git a/src/va.c b/src/va.c
index 6bc9c06..2cdbe02 100644
--- a/src/va.c
+++ b/src/va.c
@@ -58,7 +58,7 @@ static int va_debug_trace = 0;
static int vaDisplayIsValid(VADisplay dpy)
{
VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
- return pDisplayContext && pDisplayContext->vaIsValid(pDisplayContext);
+ return pDisplayContext && (pDisplayContext->vadpy_magic ==
0x789abcde) && pDisplayContext->vaIsValid(pDisplayContex
}
static void va_errorMessage(const char *msg, ...)
diff --git a/src/va_backend.h b/src/va_backend.h
index 6f858f5..e4faa79 100755
--- a/src/va_backend.h
+++ b/src/va_backend.h
@@ -398,6 +398,8 @@ struct VADriverContext
struct VADisplayContext
{
+ int vadpy_magic;
+
VADisplayContextP pNext;
VADriverContextP pDriverContext;
diff --git a/src/x11/va_x11.c b/src/x11/va_x11.c
index 5908fbe..42adb9e 100644
--- a/src/x11/va_x11.c
+++ b/src/x11/va_x11.c
@@ -189,6 +189,8 @@ VADisplay vaGetDisplay (
dri_state = calloc(1, sizeof(*dri_state));
if (pDisplayContext && pDriverContext && dri_state)
{
+ pDisplayContext->vadpy_magic = 0x789abcde;
+
pDriverContext->x11_dpy = native_dpy;
pDisplayContext->pNext = pDisplayContexts;
pDisplayContext->pDriverContext = pDriverContext;
More information about the Libva
mailing list