On 05/26/2012 12:28 PM, Jakob Bohm wrote:
> On 5/25/2012 5:30 PM, Ken Goldman wrote:
>> On 5/25/2012 3:33 AM, Jakob Bohm wrote:
>>
>>> ANSI C and POSIX free() is NOT required to handle free(NULL)
>>> as a NOP.
>>
>> I checked reputable sources (Plauger, Harbison and Steele, the ANSI
>> spec, and the IEEE POSIX spec).
>>
>> All agree that (e.g. ANSI)
>>
>> "If ptr is a null pointer, no action occurs."
>>
>>
> Which version of the ANSI Spec, and where did you get a copy?
> 
> I have to rely on secondary sources and experience using various
> implementations that claim conformance.
> 

It looks like a safe assumption to make:

The Open Group Base Specifications Issue 7
IEEE Std 1003.1-2008
Copyright © 2001-2008 The IEEE and The Open Group

[CX]  The functionality described on this reference page is aligned with
the ISO C standard. Any conflict between the requirements described here
and the ISO C standard is unintentional. This volume of POSIX.1-2008
defers to the ISO C standard.
The free() function shall cause the space pointed to by ptr to be
deallocated; that is, made available for further allocation. If ptr is a
null pointer, no action shall occur. Otherwise, if the argument does not
match a pointer earlier returned by a function in POSIX.1-2008 that
allocates memory as if by malloc(), or if the space has been deallocated
by a call to free() or realloc(), the behavior is undefined.

Any use of a pointer that refers to freed space results in undefined
behavior.

RETURN VALUE

The free() function shall not return a value.

ERRORS

No errors are defined.

And from my copy of a draft of the C99 standard:

320 Committee Draft — January 18, 1999 WG14/N869

Description

2 The free function causes the space pointed to by ptr to be
deallocated, that is, made

available for further allocation. If ptr is a null pointer, no action
occurs. Otherwise, if

the argument does not match a pointer earlier returned by the calloc,
malloc, or

realloc function, or if the space has been deallocated by a call to free
or realloc,

the behavior is undefined.

Returns

3 The free function returns no value.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to