Quoting Dwight Engen (dwight.en...@oracle.com):
> Since lxc_execute() is available through the library and is exposed via
> the API we cannot be sure the caller will immediately exit, so we should
> take care to free the allocated memory.

Right, in start.c/execute.c we want to do that.  In lxc_start.c,
lxc_execute.c, and lxc_clone.c, or in any forked tasks which immediately
exit, is where I try to be reasonable :)

This is definitely needed, thanks.

> Signed-off-by: Dwight Engen <dwight.en...@oracle.com>

Acked-by: Serge E. Hallyn <serge.hal...@ubuntu.com>

> ---
>  src/lxc/execute.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lxc/execute.c b/src/lxc/execute.c
> index d93e8e1..9bf33ca 100644
> --- a/src/lxc/execute.c
> +++ b/src/lxc/execute.c
> @@ -55,7 +55,7 @@ static char *choose_init(void)
>       ret = snprintf(retv, PATH_MAX, LXCINITDIR "/lxc/lxc-init");
>       if (ret < 0 || ret >= PATH_MAX) {
>               ERROR("pathname too long");
> -             return NULL;
> +             goto out1;
>       }
>  
>       ret = stat(retv, &mystat);
> @@ -65,7 +65,7 @@ static char *choose_init(void)
>       ret = snprintf(retv, PATH_MAX, "/usr/lib/lxc/lxc-init");
>       if (ret < 0 || ret >= PATH_MAX) {
>               ERROR("pathname too long");
> -             return NULL;
> +             goto out1;
>       }
>       ret = stat(retv, &mystat);
>       if (ret == 0)
> @@ -73,11 +73,13 @@ static char *choose_init(void)
>       ret = snprintf(retv, PATH_MAX, "/sbin/lxc-init");
>       if (ret < 0 || ret >= PATH_MAX) {
>               ERROR("pathname too long");
> -             return NULL;
> +             goto out1;
>       }
>       ret = stat(retv, &mystat);
>       if (ret == 0)
>               return retv;
> +out1:
> +     free(retv);
>       return NULL;
>  }
>  
> -- 
> 1.8.1.4
> 
> 
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite
> It's a free troubleshooting tool designed for production
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://p.sf.net/sfu/appdyn_d2d_ap2
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to