diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-05-02 11:21:11 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-05-24 10:47:49 +0200 |
commit | 524c3c0f26209f22911a980d793f13d8e6fc1887 (patch) | |
tree | 22da1f75ebb61a21b4789230791bc66f883712bd /src/core | |
parent | 178d1b2f15e7c8a46bf859ca40303be0bb42305b (diff) |
Fix read-after-free on EGL extensions
Cache the read extensions as an std::string, since the returned C string
may be not be permanent.
Change-Id: I856b2b784ab4027da25996b2bf741b30cda10e05
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
(cherry picked from commit fd2fc0d2a86f39d563720563555ca6319f8ab223)
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ozone/gl_surface_egl_qt.cpp | 6 | ||||
-rw-r--r-- | src/core/ozone/gl_surface_glx_qt.cpp | 12 | ||||
-rw-r--r-- | src/core/ozone/gl_surface_qt.cpp | 6 | ||||
-rw-r--r-- | src/core/ozone/gl_surface_qt.h | 8 |
4 files changed, 16 insertions, 16 deletions
diff --git a/src/core/ozone/gl_surface_egl_qt.cpp b/src/core/ozone/gl_surface_egl_qt.cpp index f7d162923..52ab53c38 100644 --- a/src/core/ozone/gl_surface_egl_qt.cpp +++ b/src/core/ozone/gl_surface_egl_qt.cpp @@ -144,12 +144,12 @@ void GLSurfaceEGL::ShutdownOneOff() const char *GLSurfaceEGL::GetEGLClientExtensions() { - return GLSurfaceQt::g_client_extensions; + return GLSurfaceQt::g_client_extensions.c_str(); } const char *GLSurfaceEGL::GetEGLExtensions() { - return GLSurfaceQt::g_extensions; + return GLSurfaceQt::g_extensions.c_str(); } bool GLSurfaceEGL::HasEGLClientExtension(const char *name) @@ -223,7 +223,7 @@ bool GLSurfaceEGLQt::InitializeOneOff() g_client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); g_extensions = eglQueryString(g_display, EGL_EXTENSIONS); - g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions, "EGL_KHR_surfaceless_context"); + g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions.c_str(), "EGL_KHR_surfaceless_context"); if (g_egl_surfaceless_context_supported) { scoped_refptr<GLSurface> surface = new GLSurfacelessQtEGL(gfx::Size(1, 1)); gl::GLContextAttribs attribs; diff --git a/src/core/ozone/gl_surface_glx_qt.cpp b/src/core/ozone/gl_surface_glx_qt.cpp index 5ccf5037a..79a084941 100644 --- a/src/core/ozone/gl_surface_glx_qt.cpp +++ b/src/core/ozone/gl_surface_glx_qt.cpp @@ -54,7 +54,7 @@ void GLSurfaceGLX::ShutdownOneOff() bool GLSurfaceGLX::IsCreateContextSupported() { - return ExtensionsContain(GLSurfaceQt::g_extensions, "GLX_ARB_create_context"); + return HasGLXExtension("GLX_ARB_create_context"); } bool GLSurfaceGLX::IsCreateContextRobustnessSupported() @@ -79,7 +79,7 @@ bool GLSurfaceGLX::IsCreateContextProfileSupported() bool GLSurfaceGLX::IsCreateContextES2ProfileSupported() { - return ExtensionsContain(GLSurfaceQt::g_extensions, "GLX_ARB_create_context_es2_profile"); + return HasGLXExtension("GLX_ARB_create_context_es2_profile"); } bool GLSurfaceGLX::IsOMLSyncControlSupported() @@ -89,12 +89,12 @@ bool GLSurfaceGLX::IsOMLSyncControlSupported() bool GLSurfaceGLX::HasGLXExtension(const char *name) { - return ExtensionsContain(GLSurfaceQt::g_extensions, name); + return ExtensionsContain(GLSurfaceQt::g_extensions.c_str(), name); } bool GLSurfaceGLX::IsTextureFromPixmapSupported() { - return ExtensionsContain(GLSurfaceQt::g_extensions, "GLX_EXT_texture_from_pixmap"); + return HasGLXExtension("GLX_EXT_texture_from_pixmap"); } bool GLSurfaceGLX::IsRobustnessVideoMemoryPurgeSupported() @@ -104,7 +104,7 @@ bool GLSurfaceGLX::IsRobustnessVideoMemoryPurgeSupported() const char* GLSurfaceGLX::GetGLXExtensions() { - return GLSurfaceQt::g_extensions; + return GLSurfaceQt::g_extensions.c_str(); } @@ -162,7 +162,7 @@ bool GLSurfaceGLXQt::InitializeExtensionSettingsOneOff() Display* display = static_cast<Display*>(g_display); GLSurfaceQt::g_extensions = glXQueryExtensionsString(display, 0); - g_driver_glx.InitializeExtensionBindings(g_extensions); + g_driver_glx.InitializeExtensionBindings(g_extensions.c_str()); return true; } diff --git a/src/core/ozone/gl_surface_qt.cpp b/src/core/ozone/gl_surface_qt.cpp index 8af3bd3c1..9bf16c960 100644 --- a/src/core/ozone/gl_surface_qt.cpp +++ b/src/core/ozone/gl_surface_qt.cpp @@ -64,8 +64,8 @@ namespace gl { void *GLSurfaceQt::g_display = nullptr; void *GLSurfaceQt::g_config = nullptr; -const char *GLSurfaceQt::g_client_extensions = nullptr; -const char *GLSurfaceQt::g_extensions = nullptr; +std::string GLSurfaceQt::g_client_extensions; +std::string GLSurfaceQt::g_extensions; GLSurfaceQt::~GLSurfaceQt() { @@ -86,7 +86,7 @@ GLSurfaceQt::GLSurfaceQt(const gfx::Size& size) bool GLSurfaceQt::HasEGLExtension(const char* name) { - return ExtensionsContain(g_extensions, name); + return ExtensionsContain(g_extensions.c_str(), name); } bool GLSurfaceQt::IsOffscreen() diff --git a/src/core/ozone/gl_surface_qt.h b/src/core/ozone/gl_surface_qt.h index 055b27875..8689c3a19 100644 --- a/src/core/ozone/gl_surface_qt.h +++ b/src/core/ozone/gl_surface_qt.h @@ -37,11 +37,11 @@ ** ****************************************************************************/ - - #ifndef GL_SURFACE_QT_H_ #define GL_SURFACE_QT_H_ +#include <string> + #include "ui/gfx/geometry/size.h" #include "ui/gl/gl_surface.h" @@ -71,8 +71,8 @@ protected: public: static void* g_config; static void* g_display; - static const char* g_extensions; - static const char* g_client_extensions; + static std::string g_extensions; + static std::string g_client_extensions; private: DISALLOW_COPY_AND_ASSIGN(GLSurfaceQt); |