From d09e91cac8469387feb3dc0aea515d2ad1213f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 22 Sep 2021 10:46:51 +0200 Subject: [PATCH] external: avoid crashes on eglGetString() returning a nullptr. --- doc/changelog.dox | 4 ++++ src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp | 6 +++--- src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp.template | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 17682ebc9..88cc4f4c0 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -496,6 +496,10 @@ See also: image converter plugin manager for cross-manager dependencies, broken since the removal of global shared manager state in 2020.06 (see [mosra/magnum#489](https://github.com/mosra/magnum/issues/489)) +- Implementation of the @cpp "nv-egl-incorrect-gl11-function-pointers" @ce + @ref opengl-workarounds "OpenGL workaround" could lead to a crash if + @cpp eglQueryString() @ce would return a @cpp nullptr @ce (see + [mosra/magnum#535](https://github.com/mosra/magnum/issues/535)) @subsection changelog-latest-deprecated Deprecated APIs diff --git a/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp b/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp index 89a9b0f05..172223e6a 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp +++ b/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp @@ -31,9 +31,9 @@ #include "Magnum/Platform/Implementation/OpenGLFunctionLoader.h" #ifdef MAGNUM_PLATFORM_USE_EGL -#include #include #include + #include "Magnum/GL/Context.h" #endif @@ -48,8 +48,8 @@ void flextGLInit(Magnum::GL::Context& context) { linked GL 1.0 and 1.1 functions (such as glGetString()) and one has to retrieve them explicitly using eglGetProcAddress(). */ EGLDisplay display = eglGetCurrentDisplay(); - const char* vendor = eglQueryString(display, EGL_VENDOR); - if(std::strcmp(vendor, "NVIDIA") == 0 && !context.isDriverWorkaroundDisabled("nv-egl-incorrect-gl11-function-pointers"_s)) { + const Corrade::Containers::StringView vendor = eglQueryString(display, EGL_VENDOR); + if(vendor == "NVIDIA"_s && !context.isDriverWorkaroundDisabled("nv-egl-incorrect-gl11-function-pointers"_s)) { /* GL_VERSION_1_0 */ flextGL.BlendFunc = reinterpret_cast(loader.load("glBlendFunc")); diff --git a/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp.template b/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp.template index 78f9cb082..873a6f7ff 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp.template +++ b/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp.template @@ -32,9 +32,9 @@ #include "Magnum/Platform/Implementation/OpenGLFunctionLoader.h" #ifdef MAGNUM_PLATFORM_USE_EGL -#include #include #include + #include "Magnum/GL/Context.h" #endif @@ -49,8 +49,8 @@ void flextGLInit(Magnum::GL::Context& context) { linked GL 1.0 and 1.1 functions (such as glGetString()) and one has to retrieve them explicitly using eglGetProcAddress(). */ EGLDisplay display = eglGetCurrentDisplay(); - const char* vendor = eglQueryString(display, EGL_VENDOR); - if(std::strcmp(vendor, "NVIDIA") == 0 && !context.isDriverWorkaroundDisabled("nv-egl-incorrect-gl11-function-pointers"_s)) { + const Corrade::Containers::StringView vendor = eglQueryString(display, EGL_VENDOR); + if(vendor == "NVIDIA"_s && !context.isDriverWorkaroundDisabled("nv-egl-incorrect-gl11-function-pointers"_s)) { @for category,funcs in functions: @if funcs and category in ['VERSION_1_0', 'VERSION_1_1']: