Skip to content

Instantly share code, notes, and snippets.

@wesen
Created July 28, 2017 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesen/b424f24fb8d8efdc2dc2ffe314fa5b37 to your computer and use it in GitHub Desktop.
Save wesen/b424f24fb8d8efdc2dc2ffe314fa5b37 to your computer and use it in GitHub Desktop.
commit b4c6d6083b67a00863f8243330687e8c20407257 (HEAD)
Author: Alexandru Croitor <alexandru.croitor@qt.io>
Date: 10 months ago
Check qgl_current_fbo_invalid before using qgl_current_fbo
QSG24BitTextMaskShader::useSRGB() on macOS accesses the current context
qgl_current_fbo member without first checking if it is valid.
Make sure it also checks qgl_current_fbo_invalid, thus not accidentally
dereferencing a dangling pointer.
Change-Id: I56a77de23ee3b4b271bd848506ff26e14d7b6d15
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 3eba29ba4..5ef5c7941 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -233,7 +233,8 @@ bool QSG24BitTextMaskShader::useSRGB() const
// m_useSRGB is true, but if some QOGLFBO was bound check it's texture format:
QOpenGLContext *ctx = QOpenGLContext::cur QOpenGLFramebufferObject *qfbo = QOpenGLContextPrivate::get(ctx)->qgl_current_fbo;
- return !qfbo || qfbo->format().internalTextureFormat() == GL_SRGB8_ALPHA8_EXT;
+ bool fboInvalid = QOpenGLContextPrivate::get(ctx)->qgl_current_fbo_invalid;
+ return !qfbo || fboInvalid || qfbo->format().internalTextureFormat() == GL_SRGB8_ALPHA8_EXT;
#else
return m_useSRGB;
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment