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.

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 -0000      1.115
+++ malloc.3    24 Aug 2017 01:31:52 -0000
@@ -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

Reply via email to