POSIX specifies the fmemopen() function shall fail with EINVAL when the size argument specifies a buffer size of zero. When compiled with the top of trunk, the program below aborts indicating that glibc fails to conform to this requirement. #include <assert.h> #include <errno.h> #include <stdio.h> int main (void) { char c = 0; FILE *f = fmemopen (&c, 0, "w"); printf ("%p, errno = %m\n", f); assert (f == 0 && errno == EINVAL); return 0; } 0x100002f0040, errno = Success a.out: /build/tmp/t.c:10: main: Assertion `f == 0 && (*__errno_location ()) == 22' failed.
Confirmed. The __old_fmemopen, aka fmemopen@GLIBC_2.2.5 works correctly, but the fmemopen@@GLIBC_2.22 does not.
See <http://austingroupbugs.net/view.php?id=818#c2184>. *** This bug has been marked as a duplicate of bug 11216 ***