From bc2c5bf43e1aaf399b9df08e3c33ab2c51690f7b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 30 Jul 2024 15:51:59 +0300 Subject: [PATCH] Fix checking whether GraphicsBufferView is null If the graphics buffer view is null, GraphicsBufferView::image() will point to a valid memory location but the QImage at that address is going to be null. --- .../scenes/opengl/basiceglsurfacetexture_wayland.cpp | 4 ++-- .../scenes/qpainter/qpaintersurfacetexture_wayland.cpp | 4 ++-- src/shadow.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp b/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp index 022626cda7..d22474702e 100644 --- a/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp +++ b/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp @@ -66,7 +66,7 @@ void BasicEGLSurfaceTextureWayland::update(const QRegion ®ion) bool BasicEGLSurfaceTextureWayland::loadShmTexture(GraphicsBuffer *buffer) { const GraphicsBufferView view(buffer); - if (Q_UNLIKELY(!view.image())) { + if (Q_UNLIKELY(view.isNull())) { return false; } @@ -95,7 +95,7 @@ void BasicEGLSurfaceTextureWayland::updateShmTexture(GraphicsBuffer *buffer, con } const GraphicsBufferView view(buffer); - if (Q_UNLIKELY(!view.image())) { + if (Q_UNLIKELY(view.isNull())) { return; } diff --git a/src/platformsupport/scenes/qpainter/qpaintersurfacetexture_wayland.cpp b/src/platformsupport/scenes/qpainter/qpaintersurfacetexture_wayland.cpp index 245b58a67e..14fb6b440d 100644 --- a/src/platformsupport/scenes/qpainter/qpaintersurfacetexture_wayland.cpp +++ b/src/platformsupport/scenes/qpainter/qpaintersurfacetexture_wayland.cpp @@ -21,7 +21,7 @@ QPainterSurfaceTextureWayland::QPainterSurfaceTextureWayland(QPainterBackend *ba bool QPainterSurfaceTextureWayland::create() { const GraphicsBufferView view(m_pixmap->buffer()); - if (Q_LIKELY(view.image())) { + if (Q_LIKELY(!view.isNull())) { // The buffer data is copied as the buffer interface returns a QImage // which doesn't own the data of the underlying wl_shm_buffer object. m_image = view.image()->copy(); @@ -32,7 +32,7 @@ bool QPainterSurfaceTextureWayland::create() void QPainterSurfaceTextureWayland::update(const QRegion ®ion) { const GraphicsBufferView view(m_pixmap->buffer()); - if (Q_UNLIKELY(!view.image())) { + if (Q_UNLIKELY(view.isNull())) { return; } diff --git a/src/shadow.cpp b/src/shadow.cpp index 36b13a526d..41f053c166 100644 --- a/src/shadow.cpp +++ b/src/shadow.cpp @@ -214,8 +214,8 @@ static QImage shadowTileForBuffer(GraphicsBuffer *buffer) { if (buffer) { const GraphicsBufferView view(buffer); - if (const QImage *image = view.image()) { - return image->copy(); + if (!view.isNull()) { + return view.image()->copy(); } } return QImage();