Re: [PATCH 12/21] virt-admin: Don't leak uri all over the place

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

 



On Thu, Mar 10, 2016 at 09:11:07AM +0100, Ján Tomko wrote:
On Thu, Mar 10, 2016 at 05:54:01AM +0100, Martin Kletzander wrote:
virAdmConnectGetURI() returns string that needs to be free()'d but we
haven't done that very much.


I also did:

s/ very much/

here since that didn't make sense after cleaning up this commit.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 tools/virt-admin.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index c47053639dd0..bc9ae9366280 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -69,9 +69,6 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn ATTRIBUTE_UNUSED,
     virErrorPtr error;
     char *uri = NULL;

-    if (reason == VIR_CONNECT_CLOSE_REASON_CLIENT)
-        return;
-

What is the reason for this change?


Oh, I added this here probably because of another refactoring I started,
where the two lines below were moved up, but that vanished and this
probably stayed.  Thanks for finding that out.

     error = virSaveLastError();
     uri = virAdmConnectGetURI(conn);

@@ -98,6 +95,8 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn ATTRIBUTE_UNUSED,
         virSetError(error);
         virFreeError(error);
     }
+
+    VIR_FREE(uri);
 }

 static int

This is already freed as of commit 34111a60


Yes, this series started some time ago ;)

@@ -323,7 +322,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
     int nsrvs = 0;
     size_t i;
     bool ret = false;
-    const char *uri = NULL;
+    char *uri = NULL;
     virAdmServerPtr *srvs = NULL;
     vshAdmControlPtr priv = ctl->privData;

@@ -347,6 +346,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
             virAdmServerFree(srvs[i]);
         VIR_FREE(srvs);
     }
+    VIR_FREE(uri);

     return ret;
 }

ACK to these two hunks.
Maybe s/all over the place/in cmdSrvList/ in the commit message.


Done ✓ I changed it locally to reflect that changes.

Jan

--
2.7.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]