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 stdio/18757] New: fmemopen fails to set errno on failure


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

            Bug ID: 18757
           Summary: fmemopen fails to set errno on failure
           Product: glibc
           Version: 2.21
            Status: NEW
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: msebor at redhat dot com
  Target Milestone: ---

POSIX specifies that on failure, "fmemopen() shall return a null pointer and
errno shall be set to indicate the error."  When linked against the top of
trunk, the following program abort indicating that the glibc implementation
fails to conform to this requirement (the function fails when passed an invalid
open mode but doesn't set errno).

#include <assert.h>
#include <errno.h>
#include <stdio.h>

int main (void)
{
    char c = 0;
    FILE *f = fmemopen (&c, 1, "?");
    printf ("%p, errno = %m\n", f);
    assert (f == 0 && errno == EINVAL);
    return 0;
}
(nil), errno = Success
a.out: /build/tmp/t.c:10: main: Assertion `f == 0 && (*__errno_location ()) ==
22' failed.

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


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