From a7d77e2587bd8495b4216d04fd981e529dfeb136 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Fri, 11 Feb 2022 13:56:29 +0100 Subject: [PATCH] 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 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ab8f2a52cc..093b719b2c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31472,7 +31472,8 @@ virDomainObjGetMessages(virDomainObj *vm, } } - (*msgs)[nmsgs] = NULL; + if (*msgs) + (*msgs)[nmsgs] = NULL; rv = nmsgs;