diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 60f25abd67a5138ac6943ff821b5c20b3e590695..e5fe9002419ce810fdc0919250f3fc39b17d3a34 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18598,7 +18598,7 @@ virDomainDefSetMetadata(virDomainDefPtr def, { xmlDocPtr doc = NULL; xmlNodePtr old; - xmlNodePtr new; + xmlNodePtr new = NULL; char *tmp; int ret = -1; @@ -18647,11 +18647,8 @@ virDomainDefSetMetadata(virDomainDefPtr def, xmlFreeNode(old); } - /* just delete the metadata */ - if (!metadata) - break; - - if (!(xmlAddChild(def->metadata, new))) { + if (new && + !(xmlAddChild(def->metadata, new))) { xmlFreeNode(new); virReportOOMError(); goto cleanup;