]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Avoid NULL-dereference in virDomainObjGetMessages
authorJiri Denemark <jdenemar@redhat.com>
Fri, 11 Feb 2022 12:56:29 +0000 (13:56 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 11 Feb 2022 14:06:49 +0000 (15:06 +0100)
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>
src/conf/domain_conf.c

index ab8f2a52cc32f93d57034091ce2d5cbd9c8f1820..093b719b2ca4ee17f0a77da0c694707a52a8862b 100644 (file)
@@ -31472,7 +31472,8 @@ virDomainObjGetMessages(virDomainObj *vm,
         }
     }
 
-    (*msgs)[nmsgs] = NULL;
+    if (*msgs)
+        (*msgs)[nmsgs] = NULL;
 
     rv = nmsgs;