Re: [libvirt] [PATCH] libvirt-override.c: avoid a leak upon call with invalid argument

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

 



> * python/libvirt-override.c (libvirt_virConnectBaselineCPU): Don't leak
> the xmlcpus buffer upon encountering a non-string list element.
> ---
>  python/libvirt-override.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/python/libvirt-override.c b/python/libvirt-override.c
> index a71766a..2447ad7 100644
> --- a/python/libvirt-override.c
> +++ b/python/libvirt-override.c
...
> @@ -2040,20 +2040,22 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
>      if (PyList_Check(list)) {
>          int i;
> 
>          ncpus = PyList_Size(list);
>          if ((xmlcpus = malloc(ncpus * sizeof(*xmlcpus))) == NULL)
>              return VIR_PY_INT_FAIL;
> 
>          for (i = 0; i < ncpus; i++) {
>              xmlcpus[i] = PyString_AsString(PyList_GetItem(list, i));
> -            if (xmlcpus[i] == NULL)
> +            if (xmlcpus[i] == NULL) {
> +                free(xmlcpus);
>                  return VIR_PY_INT_FAIL;
> +            }
>          }
>      }
> 
>      LIBVIRT_BEGIN_ALLOW_THREADS;
>      base_cpu = virConnectBaselineCPU(conn, xmlcpus, ncpus, flags);
>      LIBVIRT_END_ALLOW_THREADS;
> 
>      free(xmlcpus);

Ah, indeed. ACK

Jirka

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