C99 requires realloc(p,0) to either successfully allocate a 0-sized
array (just like malloc(0)) or to return NULL and leave p unchanged.

glibc treats realloc(p,0) like free(p) (as permitted by C89), and using
C99 compliant code would thus result in a double-free bug.

POSIX 2008 is ambiguous - it states that it defers to C99 requirements,
but then has the wording of the C89 implementation that permits glibc
behavior.  The proper resolution for POSIX is currently under debate:
http://austingroupbugs.net/view.php?id=400

Uli refuses to fix glibc (but somehow I'm not surprised):
http://sourceware.org/bugzilla/show_bug.cgi?id=12547

How should gnulib react?  And are there any existing GNU programs that
would break if C99 realloc semantics were enforced?

-- 
Eric Blake   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to