diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 553869a53f9..f929fddcf65 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -185,6 +185,13 @@ dri2_create_context(struct glx_screen *base, __DRIcontext *shared = NULL; if (shareList) { + /* If the shareList context is not a DRI2 context, we cannot possibly + * create a DRI2 context that shares it. + */ + if (shareList->vtable->destroy != dri2_destroy_context) { + return NULL; + } + pcp_shared = (struct dri2_context *) shareList; shared = pcp_shared->driContext; } diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c index 666423a7b15..9365224a696 100644 --- a/src/glx/dri_glx.c +++ b/src/glx/dri_glx.c @@ -587,6 +587,13 @@ dri_create_context(struct glx_screen *base, return NULL; if (shareList) { + /* If the shareList context is not a DRI context, we cannot possibly + * create a DRI context that shares it. + */ + if (shareList->vtable->destroy != dri_destroy_context) { + return NULL; + } + pcp_shared = (struct dri_context *) shareList; shared = pcp_shared->driContext; } diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index f6aeda90abb..801ac7d470b 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -383,6 +383,13 @@ drisw_create_context(struct glx_screen *base, return NULL; if (shareList) { + /* If the shareList context is not a DRISW context, we cannot possibly + * create a DRISW context that shares it. + */ + if (shareList->vtable->destroy != drisw_destroy_context) { + return NULL; + } + pcp_shared = (struct drisw_context *) shareList; shared = pcp_shared->driContext; }