From 62c8b7f6afec8f8a51d5f2d6a33b9ac5cd0b2988 Mon Sep 17 00:00:00 2001
From: Xu Yandong <xuyandong2@huawei.com>
Date: Wed, 14 Aug 2019 10:03:39 +0800
Subject: [PATCH] conf: Avoid double free when prase device xml failed

This patch fixes a possible double free. In virDomainDeviceDefParse()
if parse xml failes, then call virDomainDeviceDefFree() free dev, but
does not assign dev to NULL, so will return a not NULL pointer already
freeed.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
 src/conf/domain_conf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ac9bdc0..92b7b4a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16424,6 +16424,7 @@ virDomainDeviceDefParse(const char *xmlStr,
 
  error:
     virDomainDeviceDefFree(dev);
+    dev = NULL;
     goto cleanup;
 }
 
-- 
2.19.1

