From: Ian Campbell Subject: Re: [PATCH 02/11] xl: fix a couple of memory leaks Date: Fri, 27 Jan 2012 10:30:26 +0000 Message-ID: <1327660226.26983.157.camel@zakaz.uk.xensource.com> References: <1327598457-28261-1-git-send-email-ian.jackson@eu.citrix.com> <1327598457-28261-3-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1327598457-28261-3-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Thu, 2012-01-26 at 17:20 +0000, Ian Jackson wrote: > * dolog leaked the log message (!) > > * main() leaked the config_data (perhaps a false positive from valgrind, > but it's nicer to tidy it up). > > Signed-off-by: Ian Jackson Acked-by: Ian Campbell > --- > tools/libxl/xl.c | 1 + > tools/libxl/xl_cmdimpl.c | 3 ++- > 2 files changed, 3 insertions(+), 1 deletions(-) > > diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c > index 7b9d2c8..02a6803 100644 > --- a/tools/libxl/xl.c > +++ b/tools/libxl/xl.c > @@ -135,6 +135,7 @@ int main(int argc, char **argv) > config_file, strerror(errno)); > parse_global_config(config_file, config_data, config_len); > free(config_file); > + free(config_data); > > /* Reset options for per-command use of getopt. */ > argv += optind; > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index 7dbd812..87413c8 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -278,7 +278,7 @@ static void dolog(const char *file, int line, const char *func, char *fmt, ...) > static void dolog(const char *file, int line, const char *func, char *fmt, ...) > { > va_list ap; > - char *s; > + char *s = NULL; > int rc; > > va_start(ap, fmt); > @@ -286,6 +286,7 @@ static void dolog(const char *file, int line, const char *func, char *fmt, ...) > va_end(ap); > if (rc >= 0) > libxl_write_exactly(NULL, logfile, s, rc, NULL, NULL); > + free(s); > } > > static void printf_info(int domid,