summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <olivier.blin@softathome.com>2014-12-05 14:27:06 +0100
committerOlivier Blin <qt@blino.org>2015-03-27 16:52:06 +0000
commit9604d19a0a11b2a94aae7f31417a7dc80ce1cdf8 (patch)
treeced61acd52dbba46f334c17214e338535c760ca9
parent6ac99af0fa3cdf334b59dd3f85803872e7a4194f (diff)
Fix shm buffers init and destruction on failure
Some pointers need to be initialized in QWaylandBuffer and QWaylandShmBuffer, and checked at destruction. This avoids crashes when shm surface creation fails. Change-Id: I6f6afa3cc6c67533b5130700cbc27b271764109e Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
-rw-r--r--src/client/qwaylandbuffer_p.h5
-rw-r--r--src/client/qwaylandshmbackingstore.cpp12
2 files changed, 12 insertions, 5 deletions
diff --git a/src/client/qwaylandbuffer_p.h b/src/client/qwaylandbuffer_p.h
index 2bb9990f3..6d2bb66b3 100644
--- a/src/client/qwaylandbuffer_p.h
+++ b/src/client/qwaylandbuffer_p.h
@@ -54,7 +54,10 @@ QT_BEGIN_NAMESPACE
class Q_WAYLAND_CLIENT_EXPORT QWaylandBuffer {
public:
- QWaylandBuffer() { }
+ QWaylandBuffer()
+ : mBuffer(0)
+ {
+ }
virtual ~QWaylandBuffer() { }
wl_buffer *buffer() {return mBuffer;}
virtual QSize size() const = 0;
diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp
index 6ca65f053..598e9f160 100644
--- a/src/client/qwaylandshmbackingstore.cpp
+++ b/src/client/qwaylandshmbackingstore.cpp
@@ -58,7 +58,8 @@ QT_BEGIN_NAMESPACE
QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
const QSize &size, QImage::Format format)
- : mMarginsImage(0)
+ : mShmPool(0)
+ , mMarginsImage(0)
{
int stride = size.width() * 4;
int alloc = stride * size.height();
@@ -97,9 +98,12 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
QWaylandShmBuffer::~QWaylandShmBuffer(void)
{
delete mMarginsImage;
- munmap((void *) mImage.constBits(), mImage.byteCount());
- wl_buffer_destroy(mBuffer);
- wl_shm_pool_destroy(mShmPool);
+ if (mImage.constBits())
+ munmap((void *) mImage.constBits(), mImage.byteCount());
+ if (mBuffer)
+ wl_buffer_destroy(mBuffer);
+ if (mShmPool)
+ wl_shm_pool_destroy(mShmPool);
}
QImage *QWaylandShmBuffer::imageInsideMargins(const QMargins &margins)