bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proper realloc(p,0) behavior?


From: Pádraig Brady
Subject: Re: proper realloc(p,0) behavior?
Date: Fri, 25 Mar 2011 09:28:28 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 24/03/11 17:17, Eric Blake wrote:
> 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?
> 

For reference, here's a related dicussion which I started
when trying to figure out how to use realloc():
http://lists.gnu.org/archive/html/bug-gnulib/2009-04/threads.html#00176

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]