From 2af5dce3e7ea3e341720c4212e1d0a12ca68f41c Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 28 Aug 2018 16:29:38 +0200 Subject: 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 Reviewed-by: Pier Luigi Fiorini --- src/compositor/compositor_api/qwaylandseat.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/compositor/compositor_api/qwaylandseat.cpp') 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::Resource::fromResource(resource)->seat_object)->q_func(); + if (auto *r = QWaylandSeatPrivate::Resource::fromResource(resource)) + return static_cast(r->seat_object)->q_func(); + return nullptr; } /*! -- cgit v1.2.3