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

Martin Kletzander mkletzan at redhat.com
Thu Mar 10 08:40:32 UTC 2016


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 at redhat.com>
>> ---
>>  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 at redhat.com
>> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- 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/20160310/7d2334cb/attachment-0001.sig>


More information about the libvir-list mailing list