From: John Ferlan Date: Wed, 27 Aug 2014 19:22:33 +0000 (-0400) Subject: libxl_migration: Resolve Coverity RESOURCE_LEAK X-Git-Tag: v1.2.8-rc2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad4966d91a0dafc7667254fbe4ac56b7593644f6;p=thirdparty%2Flibvirt.git 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) --- diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index dbb5a8f89f..d7a380e4ad 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;