Because result was used to determine whether or not to free 'priv'
resources Coverity tagged the code as having a resource leak. This
change addresses that concern.
---
src/hyperv/hyperv_driver.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 601a85a..e69a232 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -121,6 +121,7 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int
flags)
virReportOOMError();
goto cleanup;
}
+ conn->privateData = priv;
if (hypervParseUri(&priv->parsedUri, conn->uri) < 0) {
goto cleanup;
@@ -199,18 +200,17 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int
flags)
goto cleanup;
}
- conn->privateData = priv;
-
result = VIR_DRV_OPEN_SUCCESS;
cleanup:
- if (result == VIR_DRV_OPEN_ERROR) {
- hypervFreePrivate(&priv);
- }
+ if (result == VIR_DRV_OPEN_ERROR)
+ conn->privateData = NULL;
VIR_FREE(username);
VIR_FREE(password);
hypervFreeObject(priv, (hypervObject *)computerSystem);
+ if (priv && !conn->privateData)
+ hypervFreePrivate(&priv);
return result;
}
--
1.7.11.7