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>
This commit is contained in:
Johan Klokkhammer Helsing 2018-08-28 16:29:38 +02:00 committed by Johan Helsing
parent 3c4ea05c75
commit db0838a117

View File

@ -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 *)