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/20005] New: fflush on a file opened with fmemopen resets position to 0


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

            Bug ID: 20005
           Summary: fflush on a file opened with fmemopen resets position
                    to 0
           Product: glibc
           Version: 2.23
            Status: NEW
          Severity: critical
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: gbs at panix dot com
  Target Milestone: ---

As of 2.23 glibc seems to have changed its behavior on an fflush of a stream
created with fmemopen, in that it resets the file position to 0.

Here's some sample code:

    char buffer[500] = "x";
    FILE *stream;
    stream = fmemopen(buffer, 500, "r+");
    fwrite("fish",sizeof(char),5,stream);
    printf("pos-1:%ld\n",ftell(stream));
    fflush(stream);
    printf("pos-2:%ld\n",ftell(stream));


On earlier versions this would result in:

pos-1:5
pos-2:5

Now it returns:

pos-1:5
pos-2:0

I verified this using Ubuntu 15.10 for the earlier version, and 16.04 for 2.23.

-- 
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]