Scanner: Don't crash when calling fromResource with nullptr

Change-Id: I85c17e50cf917a51e74fa03fcdc647def6e4bdfd
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:07:06 +02:00 committed by Johan Helsing
parent f746be7c7f
commit 3c4ea05c75

View File

@ -806,6 +806,8 @@ bool Scanner::process()
printf(" %s::Resource *%s::Resource::fromResource(struct ::wl_resource *resource)\n", interfaceName, interfaceName);
printf(" {\n");
printf(" if (Q_UNLIKELY(!resource))\n");
printf(" return nullptr;\n");
printf(" if (wl_resource_instance_of(resource, &::%s_interface, %s))\n", interfaceName, interfaceMember.constData());
printf(" return static_cast<Resource *>(resource->data);\n");
printf(" return nullptr;\n");