conf: Avoid NULL-dereference in virDomainObjGetMessages

All callers currently guarantee flags passed to virDomainObjGetMessages
are either zero or contain at least one of the supported flags. But it
doesn't mean we should not check for the possibility an unknown flag was
the only one passed to virDomainObjGetMessages.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jiri Denemark 2022-02-11 13:56:29 +01:00
parent 3a311593e5
commit a7d77e2587

View File

@ -31472,7 +31472,8 @@ virDomainObjGetMessages(virDomainObj *vm,
}
}
(*msgs)[nmsgs] = NULL;
if (*msgs)
(*msgs)[nmsgs] = NULL;
rv = nmsgs;