This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/11216] New: fmemopen returns NULL when len=0


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]