Browse Source

external: avoid crashes on eglGetString() returning a nullptr.

pull/537/head
Vladimír Vondruš 5 years ago
parent
commit
d09e91cac8
  1. 4
      doc/changelog.dox
  2. 6
      src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp
  3. 6
      src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp.template

4
doc/changelog.dox

@ -496,6 +496,10 @@ See also:
image converter plugin manager for cross-manager dependencies, broken since image converter plugin manager for cross-manager dependencies, broken since
the removal of global shared manager state in 2020.06 (see the removal of global shared manager state in 2020.06 (see
[mosra/magnum#489](https://github.com/mosra/magnum/issues/489)) [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 @subsection changelog-latest-deprecated Deprecated APIs

6
src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp vendored

@ -31,9 +31,9 @@
#include "Magnum/Platform/Implementation/OpenGLFunctionLoader.h" #include "Magnum/Platform/Implementation/OpenGLFunctionLoader.h"
#ifdef MAGNUM_PLATFORM_USE_EGL #ifdef MAGNUM_PLATFORM_USE_EGL
#include <cstring>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#endif #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 linked GL 1.0 and 1.1 functions (such as glGetString()) and one has
to retrieve them explicitly using eglGetProcAddress(). */ to retrieve them explicitly using eglGetProcAddress(). */
EGLDisplay display = eglGetCurrentDisplay(); EGLDisplay display = eglGetCurrentDisplay();
const char* vendor = eglQueryString(display, EGL_VENDOR); const Corrade::Containers::StringView vendor = eglQueryString(display, EGL_VENDOR);
if(std::strcmp(vendor, "NVIDIA") == 0 && !context.isDriverWorkaroundDisabled("nv-egl-incorrect-gl11-function-pointers"_s)) { if(vendor == "NVIDIA"_s && !context.isDriverWorkaroundDisabled("nv-egl-incorrect-gl11-function-pointers"_s)) {
/* GL_VERSION_1_0 */ /* GL_VERSION_1_0 */
flextGL.BlendFunc = reinterpret_cast<void(APIENTRY*)(GLenum, GLenum)>(loader.load("glBlendFunc")); flextGL.BlendFunc = reinterpret_cast<void(APIENTRY*)(GLenum, GLenum)>(loader.load("glBlendFunc"));

6
src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp.template vendored

@ -32,9 +32,9 @@
#include "Magnum/Platform/Implementation/OpenGLFunctionLoader.h" #include "Magnum/Platform/Implementation/OpenGLFunctionLoader.h"
#ifdef MAGNUM_PLATFORM_USE_EGL #ifdef MAGNUM_PLATFORM_USE_EGL
#include <cstring>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#endif #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 linked GL 1.0 and 1.1 functions (such as glGetString()) and one has
to retrieve them explicitly using eglGetProcAddress(). */ to retrieve them explicitly using eglGetProcAddress(). */
EGLDisplay display = eglGetCurrentDisplay(); EGLDisplay display = eglGetCurrentDisplay();
const char* vendor = eglQueryString(display, EGL_VENDOR); const Corrade::Containers::StringView vendor = eglQueryString(display, EGL_VENDOR);
if(std::strcmp(vendor, "NVIDIA") == 0 && !context.isDriverWorkaroundDisabled("nv-egl-incorrect-gl11-function-pointers"_s)) { if(vendor == "NVIDIA"_s && !context.isDriverWorkaroundDisabled("nv-egl-incorrect-gl11-function-pointers"_s)) {
@for category,funcs in functions: @for category,funcs in functions:
@if funcs and category in ['VERSION_1_0', 'VERSION_1_1']: @if funcs and category in ['VERSION_1_0', 'VERSION_1_1']:

Loading…
Cancel
Save