On Thu, Aug 24, 2017 at 11:34:52AM +1000, Damien Miller wrote:
> Hi,
>
> memset(NULL, 0, 0) is (strictly speaking) undefined behaviour, but
> there's no reason that freezero(3) needs to follow suit.
>
> This mentions that freezero(NULL, 0) is valid in the manpage, so that
> anyone who copies this API should get it right too.
Isn't this overkill? The man page already states that calling freezero()
with a NULL pointer is a no-op:
"If ptr is NULL, no action occurs."
-Otto
>
> ok?
>
> Index: malloc.3
> ===
> RCS file: /cvs/src/lib/libc/stdlib/malloc.3,v
> retrieving revision 1.115
> diff -u -p -r1.115 malloc.3
> --- malloc.3 15 May 2017 18:05:34 - 1.115
> +++ malloc.3 24 Aug 2017 01:31:52 -
> @@ -210,6 +210,12 @@ argument must be equal or smaller than t
> that returned
> .Fa ptr .
> .Fn freezero
> +may be called with a
> +.Dv NULL
> +pointer argument if the
> +.Fa size
> +argument is zero.
> +.Fn freezero
> guarantees the memory range starting at
> .Fa ptr
> with length