lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120905134937.GN19591@arwen.pp.htv.fi>
Date:	Wed, 5 Sep 2012 16:49:40 +0300
From:	Felipe Balbi <balbi@...com>
To:	liang xie <xieliang007@...il.com>
Cc:	acme@...stprotocols.net, mingo@...e.hu, paulus@...ba.org,
	linux-perf-users@...r.kernel.org, a.p.zijlstra@...llo.nl,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf tool: fix trivial memory leak while calling
 system_path()

Hi,

On Wed, Sep 05, 2012 at 09:48:54PM +0800, liang xie wrote:
> A trivial memory leak fix while calling system_path
> 
> Signed-off-by: Liang Xie <xieliang@...omi.com>
> ---
>  tools/perf/util/exec_cmd.c |    6 ++++--
>  tools/perf/util/help.c     |    1 +
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/exec_cmd.c b/tools/perf/util/exec_cmd.c
> index 7adf4ad..790cc95 100644
> --- a/tools/perf/util/exec_cmd.c
> +++ b/tools/perf/util/exec_cmd.c
> @@ -83,8 +83,8 @@ void setup_path(void)
>  {
>  	const char *old_path = getenv("PATH");
>  	struct strbuf new_path = STRBUF_INIT;
> -
> -	add_path(&new_path, perf_exec_path());
> +	const char *exec_path = perf_exec_path();
> +	add_path(&new_path, exec_path);
>  	add_path(&new_path, argv0_path);
> 
>  	if (old_path)
> @@ -95,6 +95,8 @@ void setup_path(void)
>  	setenv("PATH", new_path.buf, 1);
> 
>  	strbuf_release(&new_path);
> +	if (exec_path)

free(NULL) is safe, the check isn't needed.

> +		free((void *)exec_path);

this cast doesn't look necessary either.

-- 
balbi

Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ