Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Sep 2012 19:34:58 -0700
From:      Garrett Cooper <yanegomi@gmail.com>
To:        Kevin Lo <kevlo@FreeBSD.org>
Cc:        Konstantin Belousov <kostikbel@gmail.com>, "svn-src-head@FreeBSD.org" <svn-src-head@FreeBSD.org>, "svn-src-all@FreeBSD.org" <svn-src-all@FreeBSD.org>, "src-committers@FreeBSD.org" <src-committers@FreeBSD.org>
Subject:   Re: svn commit: r240850 - head/lib/libstand
Message-ID:  <4ACBE05F-84F8-4870-B17B-6F670E4056C8@gmail.com>
In-Reply-To: <505FC00B.5020204@FreeBSD.org>
References:  <201209230838.q8N8c6Tu056083@svn.freebsd.org> <20120923105220.GL37286@deviant.kiev.zoral.com.ua> <CAGH67wQf5whjgQmXD3Ln_-r=WsLMYrBQUBj_G-HoGf1a5F_4cg@mail.gmail.com> <505FC00B.5020204@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Sent from my iPhone

On Sep 23, 2012, at 7:06 PM, Kevin Lo <kevlo@FreeBSD.org> wrote:

> On 2012/09/24 03:27, Garrett Cooper wrote:
>> On Sun, Sep 23, 2012 at 3:52 AM, Konstantin Belousov
>> <kostikbel@gmail.com> wrote:
>>> On Sun, Sep 23, 2012 at 08:38:06AM +0000, Kevin Lo wrote:
>>>> Author: kevlo
>>>> Date: Sun Sep 23 08:38:06 2012
>>>> New Revision: 240850
>>>> URL: http://svn.freebsd.org/changeset/base/240850
>>>> 
>>>> Log:
>>>>   Avoid NULL dereference
>>>> 
>>>> Modified:
>>>>   head/lib/libstand/nfs.c
>> ...
>> 
>>> I do not see how this change is useful. libstand' Free() function handles
>>> NULL parameter fine, as well as all other free(3) implementations I am
>>> aware of.
>>     +1. free(3) should silently ignore NULL parameters passed into it.
> 
> Well, The patch is harmless. I suppose I could argue it is a safety belt
> against free(NULL) should be silently ignored.
> I have no problem changing it back, but there are two other places where
> the same comment could apply.
> 
> Index: lib/libstand/nfs.c
> ===================================================================
> --- lib/libstand/nfs.c  (revision 240879)
> +++ lib/libstand/nfs.c  (working copy)
> @@ -606,10 +606,8 @@ nfs_open(const char *upath, struct open_file *f)
>        error = 0;
> 
> out:
> -       if (newfd)
> -               free(newfd);
> -       if (path)
> -               free(path);
> +       free(newfd);
> +       free(path);
> #else
>         currfd->iodesc = desc;
> 
> @@ -1256,10 +1254,8 @@ nfs_open(const char *upath, struct open_file *f)
>        error = 0;
> 
> out:
> -       if (newfd)
> -               free(newfd);
> -       if (path)
> -               free(path);
> +       free(newfd);
> +       free(path);
> #else
>        currfd->iodesc = desc;

    Yeah -- that would be good.
Thanks,
-Garrett



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4ACBE05F-84F8-4870-B17B-6F670E4056C8>