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

Re: [libvirt] [PATCH] virExecWithHook: avoid leak on OOM error path



On Thu, Feb 04, 2010 at 12:36:25PM +0100, Jim Meyering wrote:
> 
> >From ab102cf853e3b46bf10cf0faafa643a352ed8888 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering redhat com>
> Date: Thu, 4 Feb 2010 12:25:34 +0100
> Subject: [PATCH] virExecWithHook: avoid leak on OOM error path
> 
> * src/util/util.c (virExecWithHook): Free argv_str string before
> returning upon failure to allocate space for environment.
> ---
>  src/util/util.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/src/util/util.c b/src/util/util.c
> index 7e0cd50..a01fc45 100644
> --- a/src/util/util.c
> +++ b/src/util/util.c
> @@ -625,18 +625,19 @@ virExecWithHook(virConnectPtr conn,
>      char *envp_str;
> 
>      if ((argv_str = virArgvToString(argv)) == NULL) {
>          virReportOOMError(conn);
>          return -1;
>      }
> 
>      if (envp) {
>          if ((envp_str = virArgvToString(envp)) == NULL) {
> +            VIR_FREE(argv_str);
>              virReportOOMError(conn);
>              return -1;
>          }
>          VIR_DEBUG("%s %s", envp_str, argv_str);
>          VIR_FREE(envp_str);
>      } else {
>          VIR_DEBUG0(argv_str);
>      }
>      VIR_FREE(argv_str);

ACK

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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