[libvirt] [PATCH] Free the return value of virFileFindResource

Martin Kletzander mkletzan at redhat.com
Mon Jul 7 06:49:58 UTC 2014


On Mon, Jul 07, 2014 at 08:33:37AM +0200, Ján Tomko wrote:
>Commits e18a80a and 57e5c3c switched from a getenv wrapper which
>does not allocate a string to virFileFindResource which does not,
>without freeing it.
>
>https://bugzilla.redhat.com/show_bug.cgi?id=1116427
>---
> src/locking/lock_driver_lockd.c | 2 ++
> src/remote/remote_driver.c      | 3 +++
> 2 files changed, 5 insertions(+)
>
>diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
>index c67bda6..1ca7772 100644
>--- a/src/locking/lock_driver_lockd.c
>+++ b/src/locking/lock_driver_lockd.c
>@@ -273,11 +273,13 @@ static virNetClientPtr virLockManagerLockDaemonConnectionNew(bool privileged,
>     if (virNetClientAddProgram(client, *prog) < 0)
>         goto error;
>
>+    VIR_FREE(daemonPath);
>     VIR_FREE(lockdpath);
>
>     return client;
>
>  error:
>+    VIR_FREE(daemonPath);
>     VIR_FREE(lockdpath);
>     virNetClientClose(client);
>     virObjectUnref(client);
>diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
>index 88fc977..9d8120f 100644
>--- a/src/remote/remote_driver.c
>+++ b/src/remote/remote_driver.c
>@@ -1068,6 +1068,9 @@ doRemoteOpen(virConnectPtr conn,
>     VIR_FREE(pkipath);
>     VIR_FREE(knownHostsVerify);
>     VIR_FREE(knownHosts);
>+#ifndef WIN32
>+    VIR_FREE(daemonPath);
>+#endif
>

Would this compile on windows without warning if this free was ran
unconditionally and the conditional around its declaration was removed
as well?

ACK either way,

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140707/6f8d12f5/attachment-0001.sig>


More information about the libvir-list mailing list