Re: [libvirt-php][PATCH 5/5] src: Don't leak connection_get_emulator retval

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

 



On 12/11/2017 09:02 AM, Erik Skultety wrote:
> On Mon, Dec 11, 2017 at 07:34:59AM +0100, Michal Privoznik wrote:
>> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
>> ---
>>  src/libvirt-connection.c |  2 ++
>>  src/libvirt-php.c        | 11 +++++++++--
>>  2 files changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/libvirt-connection.c b/src/libvirt-connection.c
>> index 086cd57..9e70031 100644
>> --- a/src/libvirt-connection.c
>> +++ b/src/libvirt-connection.c
>> @@ -404,6 +404,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models)
>>      char cmd[4096] = { 0 };
>>      char tmp2[16]  = { 0 };
>>      snprintf(cmd, sizeof(cmd), "%s -net nic,model=? 2>&1", tmp);
>> +    VIR_FREE(tmp);
>>
>>      FILE *fp = popen(cmd, "r");
>>      if (fp == NULL)
>> @@ -475,6 +476,7 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models)
>>
>>      char cmd[4096] = { 0 };
>>      snprintf(cmd, sizeof(cmd), "%s -soundhw help 2>&1", tmp);
>> +    VIR_FREE(tmp);
>>
> 
> 
> ^These two are unrelated to the patch, either put them in a separate patch or
> squash patches 2,4,5/5 into a single patch.

Not really. The commit message says "Don't leak connection_get_emulator
retval". Now, if you view this patch with wider context (say -U20),
you'll see that both @tmp variables hold return value of the function.
Agreed that this patch might be not that clean, but the source code is
not that clean either :-) that ship has sailed a long time ago :-(.

Michal

--
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]
  Powered by Linux