virDomainDeviceAliasIsUserAlias: tolerate NULL

Do not crash in virDomainDeviceInfoParseXML if someone provides
an 'alias' element without a 'name' attribute.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Ján Tomko 2018-03-25 21:14:21 +02:00
parent 5123e6ed1f
commit 186412fe76

View File

@ -5573,7 +5573,7 @@ virDomainDeviceDefValidateAliasesIterator(virDomainDefPtr def,
struct virDomainDefValidateAliasesData *data = opaque;
const char *alias = info->alias;
if (!alias || !virDomainDeviceAliasIsUserAlias(alias))
if (!virDomainDeviceAliasIsUserAlias(alias))
return 0;
/* Some crazy backcompat for consoles. */
@ -6702,7 +6702,7 @@ virDomainDeviceAddressParseXML(xmlNodePtr address,
bool
virDomainDeviceAliasIsUserAlias(const char *aliasStr)
{
return STRPREFIX(aliasStr, USER_ALIAS_PREFIX);
return aliasStr && STRPREFIX(aliasStr, USER_ALIAS_PREFIX);
}