[Bug stdio/11216] fmemopen returns NULL when len=0

allachan at au1 dot ibm.com sourceware-bugzilla@sourceware.org
Thu Jan 30 03:38:00 GMT 2014


https://sourceware.org/bugzilla/show_bug.cgi?id=11216

paxdiablo <allachan at au1 dot ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |allachan at au1 dot ibm.com

--- Comment #6 from paxdiablo <allachan at au1 dot ibm.com> ---
I'm not entirely sure why is this being considered a bug.

The 2013 publication of POSIX.1 at
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html
specifically states (in the return value section):

===
The fmemopen() function shall fail if:
[EINVAL]
    The size argument specifies a buffer size of zero.
===

Hence returning NULL seems to be the RIGHT thing to do.

People may well believe it's more consistent to allow it and fail on first
read, but that's not what POSIX says to do. "Shall" in standards context means
"must", there's no room for movement there unless you want to claim
non-compliance with said standard :-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.



More information about the Glibc-bugs mailing list