Re: [PATCH v2] Fix Memory Leak in virQEMUCapsInitGuestFromBinary()

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

 



> This doesn't look at all right either.  If nmachines is 0, then machines
> should already be NULL.
>

If you look at the code of virQEMUCapsGetMachineTypesCaps, you see:
int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
                                   size_t *nmachines,
                                   virCapsGuestMachinePtr **machines)
{
    size_t i;

    *nmachines = 0;
    *machines = NULL;
    if (VIR_ALLOC_N(*machines, qemuCaps->nmachineTypes) < 0)
        goto error;
    *nmachines = qemuCaps->nmachineTypes;

Even if we pass nmachines=0 to VIR_ALLOC_N , it emulates GNU behavior
of malloc(0) allocating a pointer, which is never freed, and hence
needs a VIR_FREE.




-- 
Nehal J Wani

--
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]