summaryrefslogtreecommitdiffstats
path: root/src/compositor/wayland_wrapper/qwlregion.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-08-28 16:29:38 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-08-29 12:55:22 +0000
commit2af5dce3e7ea3e341720c4212e1d0a12ca68f41c (patch)
tree9bd99396a96089e29efba439f75115db0c6d9a4c /src/compositor/wayland_wrapper/qwlregion.cpp
parent6f68cada7aa652ef67a4cabf3515619088759d33 (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/wayland_wrapper/qwlregion.cpp')
-rw-r--r--src/compositor/wayland_wrapper/qwlregion.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compositor/wayland_wrapper/qwlregion.cpp b/src/compositor/wayland_wrapper/qwlregion.cpp
index 040538411..52c19e946 100644
--- a/src/compositor/wayland_wrapper/qwlregion.cpp
+++ b/src/compositor/wayland_wrapper/qwlregion.cpp
@@ -54,7 +54,9 @@ Region::~Region()
Region *Region::fromResource(struct ::wl_resource *resource)
{
- return static_cast<Region *>(Resource::fromResource(resource)->region_object);
+ if (auto *r = Resource::fromResource(resource))
+ return static_cast<Region *>(r->region_object);
+ return nullptr;
}
void Region::region_destroy_resource(Resource *)