summaryrefslogtreecommitdiffstats
path: root/tests
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 /tests
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 'tests')
-rw-r--r--tests/auto/client/shared/mocksurface.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/auto/client/shared/mocksurface.cpp b/tests/auto/client/shared/mocksurface.cpp
index 82ce37acb..4de4265d7 100644
--- a/tests/auto/client/shared/mocksurface.cpp
+++ b/tests/auto/client/shared/mocksurface.cpp
@@ -107,7 +107,9 @@ bool Surface::isMapped() const
Surface *Surface::fromResource(struct ::wl_resource *resource)
{
- return static_cast<Surface *>(Resource::fromResource(resource)->surface_object);
+ if (auto *r = Resource::fromResource(resource))
+ return static_cast<Surface *>(r->surface_object);
+ return nullptr;
}
void Surface::surface_destroy_resource(Resource *)