[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 12/19] libxl_migration: Resolve Coverity RESOURCE_LEAK



In libxlDomainMigrationPrepare() if the uri_in is false, then
'hostname' is allocated and used "generically" in the routine,
but not freed.  Conversely, if uri_in is true, then a uri is
allocated and hostname is set to the uri->hostname value and
likewise generically used.

At function exit, hostname wasn't free'd in the !uri_in path,
so that was added.  To just make it clearer on usage the else
path became the call to virURIFree() although I suppose technically
it didn't have to since it would be a call using (NULL)

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/libxl/libxl_migration.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 53ae63a..0b562f7 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -412,7 +412,10 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
     }
 
  done:
-    virURIFree(uri);
+    if (!uri_in)
+        VIR_FREE(hostname);
+    else
+        virURIFree(uri);
     if (vm)
         virObjectUnlock(vm);
     return ret;
-- 
1.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]