This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/11216] New: fmemopen returns NULL when len=0
- From: "alexshinn at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 24 Jan 2010 11:35:53 -0000
- Subject: [Bug libc/11216] New: fmemopen returns NULL when len=0
- Reply-to: sourceware-bugzilla at sourceware dot org
The following program prints "(nil)" demonstrating the problem:
int main (int argc, char **argv) {
char buf[] = "";
FILE *in = fmemopen(buf, 0, "r");
fprintf(stderr, "%p\n", in);
}
As a general-purpose utility for converting arbitrary strings
to streams it makes no more sense to forbid empty strings
(which would simply return EOF immediately) than it does to
forbid empty files or /dev/null.
[However, since it doesn't make sense to have an output stream
with an empty buffer, it seems reasonable to continue to return
NULL for the "w"rite case.]
In the meantime, as a workaround in my own applications I will
wrap fmemopen to open /dev/null in this case.
--
Summary: fmemopen returns NULL when len=0
Product: glibc
Version: 2.10
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: alexshinn at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=11216
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.