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

Re: [libvirt] [PATCH] virStoragePoolSourceListNewSource: avoid unconditional leak



On Tue, Feb 02, 2010 at 08:00:59PM +0100, Jim Meyering wrote:
> The buffer allocated by VIR_ALLOC here is never used, and
> the sole pointer to it is overwritten by this stmt:
> 
>      source = &list->sources[list->nsources++];
> 
> 
> >From 52cf50def236ab61298ebbba39fcaf89d440f4ec Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering redhat com>
> Date: Tue, 2 Feb 2010 19:59:14 +0100
> Subject: [PATCH] virStoragePoolSourceListNewSource: avoid unconditional leak
> 
> * src/conf/storage_conf.c (virStoragePoolSourceListNewSource):
> Remove an unused (and leaked) allocation.
> ---
>  src/conf/storage_conf.c |    6 ------
>  1 files changed, 0 insertions(+), 6 deletions(-)
> 
> diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
> index bd34f5e..62b8394 100644
> --- a/src/conf/storage_conf.c
> +++ b/src/conf/storage_conf.c
> @@ -1692,17 +1692,11 @@ virStoragePoolSourcePtr
>  virStoragePoolSourceListNewSource(virConnectPtr conn,
>                                    virStoragePoolSourceListPtr list)
>  {
>      virStoragePoolSourcePtr source;
> 
> -    if (VIR_ALLOC(source) < 0) {
> -        virReportOOMError(conn);
> -        return NULL;
> -    }
> -
>      if (VIR_REALLOC_N(list->sources, list->nsources+1) < 0) {
> -        VIR_FREE(source);
>          virReportOOMError(conn);
>          return NULL;
>      }
> 
>      source = &list->sources[list->nsources++];

  good catch! ACK

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


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