Browse Source

allow fmemopen with zero size

previously, POSIX erroneously required this to fail with EINVAL
despite the traditional glibc implementation, on which the POSIX
interface was based, allowing it. the resolution of Austin Group issue
818 removes the requirement to fail.
master
Rich Felker 7 years ago
parent
commit
95dfa3dd12
  1. 2
      src/stdio/fmemopen.c

2
src/stdio/fmemopen.c

@ -83,7 +83,7 @@ FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode)
struct mem_FILE *f; struct mem_FILE *f;
int plus = !!strchr(mode, '+'); int plus = !!strchr(mode, '+');
if (!size || !strchr("rwa", *mode)) { if (!strchr("rwa", *mode)) {
errno = EINVAL; errno = EINVAL;
return 0; return 0;
} }

Loading…
Cancel
Save