Commit 9bb59c5c by Courtney Goeltzenleuchter Committed by Commit Bot

Do not call eglMakeCurrent with invalid parameters

When releasing the thread only call makeCurrent if we have a display to use. Calling with EGL_NO_DISPLAY is not valid (though some devices allow it.) Bug: angleproject:3102 Change-Id: I2cf48011294d0264d3b1cb0318a2a80715e37f60 Reviewed-on: https://chromium-review.googlesource.com/c/1436840Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
parent 7085305f
......@@ -771,12 +771,35 @@ EGLSurface EGLAPIENTRY EGL_CreatePbufferFromClientBuffer(EGLDisplay dpy,
EGLBoolean EGLAPIENTRY EGL_ReleaseThread(void)
{
// Explicitly no global mutex lock because eglReleaseThread forwards its implementation to
// eglMakeCurrent
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("()");
Thread *thread = egl::GetCurrentThread();
EGL_MakeCurrent(EGL_NO_DISPLAY, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE);
Surface *previousDraw = thread->getCurrentDrawSurface();
Surface *previousRead = thread->getCurrentReadSurface();
gl::Context *previousContext = thread->getContext();
egl::Display *previousDisplay = thread->getCurrentDisplay();
// Only call makeCurrent if the context or surfaces have changed.
if (previousDraw != EGL_NO_SURFACE || previousRead != EGL_NO_SURFACE ||
previousContext != EGL_NO_CONTEXT)
{
// Release the surface from the previously-current context, to allow
// destroyed surfaces to delete themselves.
if (previousContext != nullptr && previousDisplay != EGL_NO_DISPLAY)
{
ANGLE_EGL_TRY_RETURN(thread, previousContext->releaseSurface(previousDisplay),
"eglReleaseThread", nullptr, EGL_FALSE);
}
if (previousDisplay != EGL_NO_DISPLAY)
{
ANGLE_EGL_TRY_RETURN(thread, previousDisplay->makeCurrent(nullptr, nullptr, nullptr),
"eglReleaseThread", nullptr, EGL_FALSE);
}
SetContextCurrent(thread, nullptr);
}
thread->setSuccess();
return EGL_TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment