[Bug libstdc++/13858] New: Bad error handling in basic_filebuf::imbue

peturr02 at ru dot is gcc-bugzilla@gcc.gnu.org
Sun Jan 25 17:39:00 GMT 2004


basic_filebuf::imbue currently calls _M_terminate_output() (which calls
overflow()) like this:

                    }
                }
              else if (_M_writing && (__testvalid = _M_terminate_output()))
                _M_set_buffer(-1);
            }
        }

      if (__testvalid)
        _M_codecvt = _M_codecvt_tmp;
    }

There are two problems with this:
1) Failures in overflow() are not reported;
2) If overflow() fails, _M_codecvt is not updated. After imbue returns,
pubimbue assigns __loc to _M_buf_locale, which may cause the facet pointed
to by _M_codecvt to be deleted, leaving _M_codecvt as a dangling pointer.

Both problems can probably be solved by throwing an exception if overflow()
fails.

-- 
           Summary: Bad error handling in basic_filebuf::imbue
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: peturr02 at ru dot is
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list