This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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 libstdc++/17215] New: __basic_file<char>::close ignores errors


__basic_file<char>::close ignores the return value of fclose(3).  This
call can fail and set errno to a variety of values (ENOSPC, EINTR,
etc.).  Aside from not notifying the client code (e.g. by setting
failbit in an enclosing fstream), this can also cause a memory leak as
the FILE data structure won't be de-allocated by a failed fclose and
__basic_file<char>::close discards it regardless.

Similarly, in the case where _M_cfile_created is false,
__basic_file<char>::close ignores the return value of this->sync(),
which is just a call to fflush(3).  This is not quite as bad (as it
can't cause a memory leak), but is still arguably wrong.

-- 
           Summary: __basic_file<char>::close ignores errors
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ken at xorian dot net
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17215


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