aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2012-08-23 18:05:44 -0700
committerJesse Hall <jessehall@google.com>2012-08-24 10:41:07 -0700
commit425be59a9fbc663fd7ac43cb7f447b4230c019d3 (patch)
tree3a025f969c0fbbd617e5ed9de40bb6f32eadea37 /emulator
parent3246083057e51e1e0b8f1b73a7600215eca83d4e (diff)
downloadsdk-425be59a9fbc663fd7ac43cb7f447b4230c019d3.zip
sdk-425be59a9fbc663fd7ac43cb7f447b4230c019d3.tar.gz
sdk-425be59a9fbc663fd7ac43cb7f447b4230c019d3.tar.bz2
Check that the native display is valid before using it
EglOS::getDefaultDisplay() can return an invalid display, e.g. on X11 if $DISPLAY is not set. This is called from the EglGlobalInfo constructor, which doesn't have a good way to indicate failure. So instead EglGlobalInfo::addDisplay() checks that the display is valid before wrapping it in a EglDisplay. Bug: 7020498 Change-Id: Id18fc568dae5bff4b45b706f3322ae5e4785d95d
Diffstat (limited to 'emulator')
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp3
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp4
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglOsApi.h1
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp4
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp4
5 files changed, 16 insertions, 0 deletions
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp
index f39b36e..8e5b462 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp
@@ -56,6 +56,9 @@ EglDisplay* EglGlobalInfo::addDisplay(EGLNativeDisplayType dpy,EGLNativeInternal
if((*it).second == dpy) return (*it).first;
}
+ if (!EglOS::validNativeDisplay(idpy))
+ return NULL;
+
EglDisplay* p_dpy = new EglDisplay(idpy);
if(p_dpy) {
m_displays[p_dpy] = dpy;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp b/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
index b5e7d67..fd3cb0b 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
@@ -103,6 +103,10 @@ void queryConfigs(EGLNativeDisplayType dpy,int renderableType,ConfigsList& listO
}
}
+bool validNativeDisplay(EGLNativeInternalDisplayType dpy) {
+ return true;
+}
+
bool validNativeWin(EGLNativeDisplayType dpy, EGLNativeWindowType win) {
unsigned int width,height;
return nsGetWinDims(win,&width,&height);
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h b/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h
index c166220..942c705 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h
+++ b/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h
@@ -37,6 +37,7 @@ namespace EglOS{
bool releasePbuffer(EGLNativeInternalDisplayType dis,EGLNativeSurfaceType pb);
bool destroyContext(EGLNativeInternalDisplayType dpy,EGLNativeContextType ctx);
bool releaseDisplay(EGLNativeInternalDisplayType dpy);
+ bool validNativeDisplay(EGLNativeInternalDisplayType dpy);
bool validNativeWin(EGLNativeInternalDisplayType dpy,EGLNativeSurfaceType win);
bool validNativeWin(EGLNativeInternalDisplayType dpy,EGLNativeWindowType win);
bool validNativePixmap(EGLNativeInternalDisplayType dpy,EGLNativeSurfaceType pix);
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp b/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
index c11c547..460c0b6 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
@@ -426,6 +426,10 @@ void queryConfigs(EGLNativeInternalDisplayType display,int renderableType,Config
}
}
+bool validNativeDisplay(EGLNativeInternalDisplayType dpy) {
+ return dpy != NULL;
+}
+
bool validNativeWin(EGLNativeInternalDisplayType dpy,EGLNativeWindowType win) {
return IsWindow(win);
}
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp b/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
index a421db9..c362210 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
@@ -171,6 +171,10 @@ void queryConfigs(EGLNativeDisplayType dpy,int renderableType,ConfigsList& listO
XFree(frmtList);
}
+bool validNativeDisplay(EGLNativeInternalDisplayType dpy) {
+ return dpy != NULL;
+}
+
bool validNativeWin(EGLNativeDisplayType dpy,EGLNativeWindowType win) {
Window root;
int tmp;