Ticket #1574: fix-ptime-operator-bug1574.patch

File fix-ptime-operator-bug1574.patch, 1.3 KB (added by christian.stimming@…, 12 years ago)

Patch for fixing this bug by querying ostream::fail() before doing anything in the operator<< of ptime and time_duration

  • boost/date_time/posix_time/posix_time_io.hpp

    old new  
    4545  std::basic_ostream<CharT, TraitsT>&
    4646  operator<<(std::basic_ostream<CharT, TraitsT>& os,
    4747             const ptime& p) {
     48    if (os.fail())
     49      return os;
    4850    boost::io::ios_flags_saver iflags(os);
    4951    typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet;
    5052    typedef std::time_put<CharT>                  std_ptime_facet;
     
    112114  std::basic_ostream<CharT, TraitsT>&
    113115  operator<<(std::basic_ostream<CharT, TraitsT>& os,
    114116             const boost::posix_time::time_period& p) {
     117    if (os.fail())
     118      return os;
    115119    boost::io::ios_flags_saver iflags(os);
    116120    typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet;
    117121    typedef std::time_put<CharT>                  std_time_facet;
     
    178182  std::basic_ostream<CharT, Traits>&
    179183  operator<<(std::basic_ostream<CharT, Traits>& os, const time_duration& td)
    180184  {
     185    if (os.fail())
     186      return os;
    181187    boost::io::ios_flags_saver iflags(os);
    182188    typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet;
    183189    typedef std::time_put<CharT>                  std_ptime_facet;