diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2018-08-28 16:29:38 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2018-08-29 12:55:22 +0000 |
commit | 2af5dce3e7ea3e341720c4212e1d0a12ca68f41c (patch) | |
tree | 9bd99396a96089e29efba439f75115db0c6d9a4c /src/compositor/compositor_api/qwaylandseat.cpp | |
parent | 6f68cada7aa652ef67a4cabf3515619088759d33 (diff) |
Compositor: Fix nullptr dereferences in fromResource functions
If there was no resource for the given wl_resource*, don't try to dereference
it.
Change-Id: I3a27a5805699148bb26029e8b4179042c3c1117a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandseat.cpp')
-rw-r--r-- | src/compositor/compositor_api/qwaylandseat.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp index 957f5ea83..60d4d6fd9 100644 --- a/src/compositor/compositor_api/qwaylandseat.cpp +++ b/src/compositor/compositor_api/qwaylandseat.cpp @@ -631,7 +631,9 @@ bool QWaylandSeat::isOwner(QInputEvent *inputEvent) const */ QWaylandSeat *QWaylandSeat::fromSeatResource(struct ::wl_resource *resource) { - return static_cast<QWaylandSeatPrivate *>(QWaylandSeatPrivate::Resource::fromResource(resource)->seat_object)->q_func(); + if (auto *r = QWaylandSeatPrivate::Resource::fromResource(resource)) + return static_cast<QWaylandSeatPrivate *>(r->seat_object)->q_func(); + return nullptr; } /*! |