Commit 3cf11ff4 by Geoff Lang

Make sure the given display is a valid pointer.

EGL functions are supposed to return EGL_BAD_DISPLAY when the display is an invalid pointer. Since there is very rarely more than one simultaneous display, iterating through the map is not costly. BUG=angleproject:970 Change-Id: I3d9b842a49c5c99f9b8fad3d7ef53f9f5d3057ba Reviewed-on: https://chromium-review.googlesource.com/287342Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 585f2a84
......@@ -713,6 +713,20 @@ bool Display::isValidNativeWindow(EGLNativeWindowType window) const
return mImplementation->isValidNativeWindow(window);
}
bool Display::isValidDisplay(const egl::Display *display)
{
const DisplayMap *displayMap = GetDisplayMap();
for (const auto &displayPair : *displayMap)
{
if (displayPair.second == display)
{
return true;
}
}
return false;
}
bool Display::isValidNativeDisplay(EGLNativeDisplayType display)
{
// TODO(jmadill): handle this properly
......
......@@ -81,6 +81,7 @@ class Display final : angle::NonCopyable
bool isValidSurface(egl::Surface *surface) const;
bool isValidNativeWindow(EGLNativeWindowType window) const;
static bool isValidDisplay(const egl::Display *display);
static bool isValidNativeDisplay(EGLNativeDisplayType display);
static bool hasExistingWindowSurface(EGLNativeWindowType window);
......
......@@ -22,12 +22,17 @@ Error ValidateDisplay(const Display *display)
{
if (display == EGL_NO_DISPLAY)
{
return Error(EGL_BAD_DISPLAY);
return Error(EGL_BAD_DISPLAY, "display is EGL_NO_DISPLAY.");
}
if (!Display::isValidDisplay(display))
{
return Error(EGL_BAD_DISPLAY, "display is not a valid display.");
}
if (!display->isInitialized())
{
return Error(EGL_NOT_INITIALIZED);
return Error(EGL_NOT_INITIALIZED, "display is not initialized.");
}
return Error(EGL_SUCCESS);
......
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