summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-02 11:21:11 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-02 18:58:02 +0000
commitfd2fc0d2a86f39d563720563555ca6319f8ab223 (patch)
tree9786f60e75c6a8aafae976bc8b95d8835555585a /src/core
parent726cefe2063c5d795d8333fcfd96ca759bbf5eb2 (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. Pick-to: 6.3 6.2 5.15 Change-Id: I856b2b784ab4027da25996b2bf741b30cda10e05 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ozone/gl_surface_egl_qt.cpp6
-rw-r--r--src/core/ozone/gl_surface_glx_qt.cpp12
-rw-r--r--src/core/ozone/gl_surface_qt.cpp6
-rw-r--r--src/core/ozone/gl_surface_qt.h8
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 fa2fdc0bb..23dd8ff90 100644
--- a/src/core/ozone/gl_surface_egl_qt.cpp
+++ b/src/core/ozone/gl_surface_egl_qt.cpp
@@ -159,12 +159,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)
@@ -243,7 +243,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 7110a00df..e05c198d8 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 926657348..9fb46e9ca 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;
};
}