Util-Linux package development
 help / color / mirror / Atom feed
From: yumkam@gmail.com (Yuriy M. Kaminskiy)
To: util-linux@vger.kernel.org
Subject: Re: [PATCH 4/5] lib: avoid double free in loopdev.c
Date: Wed, 20 Apr 2016 01:52:38 +0300	[thread overview]
Message-ID: <m3ega1jjnt.fsf@gmail.com> (raw)
In-Reply-To: 1461098145-2988-5-git-send-email-kerolasa@iki.fi

Sami Kerola <kerolasa@iki.fi> writes:

> Found with scan-build.
>
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  lib/loopdev.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/loopdev.c b/lib/loopdev.c
> index 9ae61da..ca5d2f4 100644
> --- a/lib/loopdev.c
> +++ b/lib/loopdev.c
> @@ -460,6 +460,7 @@ static int loop_scandir(const char *dirname, int **ary, int hasprefix)
>  			tmp = realloc(*ary, arylen * sizeof(int));
>  			if (!tmp) {
>  				free(*ary);
> +				ary = NULL;

This cannot have any effect. Probably you wanted
                                *ary = NULL;
                                
>  				closedir(dir);
>  				return -1;
>  			}


  reply	other threads:[~2016-04-19 22:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-19 20:35 [PATCH 0/5] pull: couple clang scan-build fixes Sami Kerola
2016-04-19 20:35 ` [PATCH 1/5] build-sys: test functions does not return void Sami Kerola
2016-04-19 20:35 ` [PATCH 2/5] libmount: fix memory leak Sami Kerola
2016-04-19 20:35 ` [PATCH 3/5] setpwnam: " Sami Kerola
2016-04-19 20:35 ` [PATCH 4/5] lib: avoid double free in loopdev.c Sami Kerola
2016-04-19 22:52   ` Yuriy M. Kaminskiy [this message]
2016-04-20 21:06     ` Sami Kerola
2016-04-19 20:35 ` [PATCH 5/5] getopt: fix memory leaks and integer overflows [ASAN & valgrind] Sami Kerola
2016-04-22  9:35   ` Karel Zak
2016-04-22  9:32 ` [PATCH 0/5] pull: couple clang scan-build fixes Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3ega1jjnt.fsf@gmail.com \
    --to=yumkam@gmail.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox