diff options
| author | 2017-09-29 15:57:42 -0700 | |
|---|---|---|
| committer | 2017-09-29 15:57:42 -0700 | |
| commit | 09fc8f95792fdae9715668d5ce78050f0268adfc (patch) | |
| tree | 875043ec01fe71153af47ae738fa22dd9ce7a29f | |
| parent | f71878b87b50de7d80de05ef30bf85a892f999db (diff) | |
Handle glGetString returning NULL
When two contexts are shared, and one is lost/reset, the other can be
lost as well. A lost context can return NULL from glGetString. On the
first eglMakeCurrent to a context, we fetch the extension list, and
weren't checking for NULL, leading to a crash in the rare case where a
context is lost and then another context sharing with it is made
current for the first time.
Bug: 64024627
Test: dEQP-EGL.functional.robustness.reset_context.shaders.infinite_loop.shared_context_status.*
Change-Id: Ib7e1b932490ec587df159e9e461c211d3dac35d4
| -rw-r--r-- | opengl/libs/EGL/egl_object.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp index 623878062b..d8005d8ebf 100644 --- a/opengl/libs/EGL/egl_object.cpp +++ b/opengl/libs/EGL/egl_object.cpp @@ -113,17 +113,23 @@ void egl_context_t::onMakeCurrent(EGLSurface draw, EGLSurface read) { if (gl_extensions.empty()) { // call the implementation's glGetString(GL_EXTENSIONS) const char* exts = (const char *)gEGLImpl.hooks[version]->gl.glGetString(GL_EXTENSIONS); - gl_extensions = exts; - if (gl_extensions.find("GL_EXT_debug_marker") == std::string::npos) { - gl_extensions.insert(0, "GL_EXT_debug_marker "); - } - // tokenize the supported extensions for the glGetStringi() wrapper - std::stringstream ss; - std::string str; - ss << gl_extensions; - while (ss >> str) { - tokenized_gl_extensions.push_back(str); + // If this context is sharing with another context, and the other context was reset + // e.g. due to robustness failure, this context might also be reset and glGetString can + // return NULL. + if (exts) { + gl_extensions = exts; + if (gl_extensions.find("GL_EXT_debug_marker") == std::string::npos) { + gl_extensions.insert(0, "GL_EXT_debug_marker "); + } + + // tokenize the supported extensions for the glGetStringi() wrapper + std::stringstream ss; + std::string str; + ss << gl_extensions; + while (ss >> str) { + tokenized_gl_extensions.push_back(str); + } } } } |