From: Pavel Hrdina Date: Wed, 11 Mar 2020 12:25:59 +0000 (+0100) Subject: domain_conf: fix NULL dereference on error in virDomainObjCopyPersistentDef X-Git-Tag: v6.10.0-rc1~141 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b96174d9f2dcf0197bb6e58eea3fbbda17043478;p=thirdparty%2Flibvirt.git domain_conf: fix NULL dereference on error in virDomainObjCopyPersistentDef The issue was introduced together with the function itself by commit . Calling `virDomainObjGetPersistentDef` may return NULL which is later passed to `virDomainDefFormat` where the `def` attribute is marked as NONNULL and later in `virDomainDefFormatInternalSetRootName` it is actually defererenced without any other check. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5c30227212..bf97e0505d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30933,6 +30933,12 @@ virDomainObjCopyPersistentDef(virDomainObjPtr dom, virDomainDefPtr cur; cur = virDomainObjGetPersistentDef(xmlopt, dom, parseOpaque); + if (!cur) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to get persistent definition object")); + return NULL; + } + return virDomainDefCopy(cur, xmlopt, parseOpaque, false); }