egl: Return EGL_BAD_MATCH for invalid share_list

From the eglspec.1.5: "An EGL_BAD_MATCH is generated if [...]
share context was created on a different display than
the one referenced by config."

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6414
Signed-off-by: Mykhailo Skorokhodov<mykhailo.skorokhodov@globallogic.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16368>
This commit is contained in:
Michael Skorokhodov 2022-05-06 12:28:21 +03:00 committed by Marge Bot
parent a418ab6654
commit 5e76850cff
1 changed files with 11 additions and 0 deletions

View File

@ -857,6 +857,17 @@ eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
if (!share && share_list != EGL_NO_CONTEXT)
RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
else if(share && share->Resource.Display != disp) {
/* From the spec.
*
* "An EGL_BAD_MATCH error is generated if an OpenGL or OpenGL ES
* context is requested and any of: [...]
*
* * share context was created on a different display
* than the one reference by config."
*/
RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_NO_CONTEXT);
}
context = disp->Driver->CreateContext(disp, conf, share, attrib_list);
ret = (context) ? _eglLinkContext(context) : EGL_NO_CONTEXT;