[lxc-devel] [PATCH] fix getline(3) memory leaks

Serge Hallyn serge.hallyn at ubuntu.com
Tue May 21 22:07:54 UTC 2013


Quoting Dwight Engen (dwight.engen at oracle.com):
> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
> ---
>  src/lxc/attach.c | 2 +-
>  src/lxc/cgroup.c | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/attach.c b/src/lxc/attach.c
> index a7e9074..d8b4915 100644
> --- a/src/lxc/attach.c
> +++ b/src/lxc/attach.c
> @@ -114,6 +114,7 @@ struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid)
>  		}
>  	}
>  

does this need to be

	if (line)
		free(line);
?

> +	free(line);
>  	fclose(proc_file);
>  
>  	if (!found) {
> @@ -145,7 +146,6 @@ struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid)
>  
>  out_error:
>  	free(info);
> -	free(line);
>  	return NULL;
>  }
>  
> diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c
> index 44266de..2ffbb54 100644
> --- a/src/lxc/cgroup.c
> +++ b/src/lxc/cgroup.c
> @@ -503,6 +503,7 @@ static char *get_all_cgroups(void)
>  	}
>  
>  out:
> +	free(line);
>  	fclose(f);
>  	return ret;
>  }
> -- 
> 1.8.1.4
> 
> 
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service 
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list