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:
parent
3c4ea05c75
commit
db0838a117
@ -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 *)
|
||||
|
Loading…
x
Reference in New Issue
Block a user