This is the mail archive of the gcc-patches@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]

[v3] Fix a remaining end iterator issue with time_put::put


Hi,

could happen when (__c == 'E' || __c == 'O').

Tested x86-linux, committed.

Paolo.

//////////
2003-10-29  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/locale_facets.tcc (time_put::put): Absolutely
	avoid dereferencing end iterators; clean up.

	* include/bits/locale_facets.tcc (num_get::_M_extract_float,
	num_get::_M_extract_int): Minor tweak.
diff -prN libstdc++-v3-orig/include/bits/locale_facets.tcc libstdc++-v3/include/bits/locale_facets.tcc
*** libstdc++-v3-orig/include/bits/locale_facets.tcc	Wed Oct 29 09:59:24 2003
--- libstdc++-v3/include/bits/locale_facets.tcc	Wed Oct 29 12:59:18 2003
*************** namespace std
*** 219,228 ****
  	    {
  	      // Scientific notation.
  	      __xtrc += __e ? _S_atoms_in[_S_ie] : _S_atoms_in[_S_iE];
- 	      ++__beg;
  	      
  	      // Remove optional plus or minus sign, if they exist.
! 	      if (__beg != __end)
  		{
  		  const bool __plus = __traits_type::eq(*__beg, __lit[_S_iplus]);
  		  if (__plus || __traits_type::eq(*__beg, __lit[_S_iminus]))
--- 219,227 ----
  	    {
  	      // Scientific notation.
  	      __xtrc += __e ? _S_atoms_in[_S_ie] : _S_atoms_in[_S_iE];
  	      
  	      // Remove optional plus or minus sign, if they exist.
! 	      if (++__beg != __end)
  		{
  		  const bool __plus = __traits_type::eq(*__beg, __lit[_S_iplus]);
  		  if (__plus || __traits_type::eq(*__beg, __lit[_S_iminus]))
*************** namespace std
*** 327,335 ****
  	  if (__beg != __end && __traits_type::eq(*__beg, __lit[_S_izero]))
  	    {
  	      __xtrc += _S_atoms_in[_S_izero];
- 	      ++__beg; 
  	      
! 	      if (__beg != __end)
  		{
  		  const bool __x = __traits_type::eq(*__beg, __lit[_S_ix]);
  		  if (__x || __traits_type::eq(*__beg, __lit[_S_iX]))
--- 326,333 ----
  	  if (__beg != __end && __traits_type::eq(*__beg, __lit[_S_izero]))
  	    {
  	      __xtrc += _S_atoms_in[_S_izero];
  	      
! 	      if (++__beg != __end)
  		{
  		  const bool __x = __traits_type::eq(*__beg, __lit[_S_ix]);
  		  if (__x || __traits_type::eq(*__beg, __lit[_S_iX]))
*************** namespace std
*** 1995,2025 ****
      {
        const locale __loc = __io.getloc();
        ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
!       while (__beg != __end)
  	{
! 	  const _CharT __tmp = *__beg;
! 	  ++__beg;
! 	  if (__ctype.narrow(__tmp, 0) == '%' && __beg != __end)
  	    {
  	      char __format;
  	      char __mod = 0;
  	      const char __c = __ctype.narrow(*__beg, 0);
! 	      ++__beg;
! 	      if (__c == 'E' || __c == 'O')
  		{
  		  __mod = __c;
  		  __format = __ctype.narrow(*__beg, 0);
- 		  ++__beg;
  		}
  	      else
! 		__format = __c;
! 	      __s = this->do_put(__s, __io, __fill, __tm, __format, __mod);
  	    }
  	  else
! 	    {
! 	      *__s = __tmp;
! 	      ++__s;
! 	    }
  	}
        return __s;
      }
--- 1993,2024 ----
      {
        const locale __loc = __io.getloc();
        ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
!       for (; __beg != __end; ++__beg)
  	{
! 	  if (__ctype.narrow(*__beg, 0) != '%')
! 	    {
! 	      *__s = *__beg;
! 	      ++__s;
! 	    }
! 	  else if (++__beg != __end)
  	    {
  	      char __format;
  	      char __mod = 0;
  	      const char __c = __ctype.narrow(*__beg, 0);
! 	      if (__c != 'E' && __c != 'O')
! 		__format = __c;
! 	      else if (++__beg != __end)
  		{
  		  __mod = __c;
  		  __format = __ctype.narrow(*__beg, 0);
  		}
  	      else
! 		break;
! 	      __s = this->do_put(__s, __io, __fill, __tm,
! 				 __format, __mod);
  	    }
  	  else
! 	    break;
  	}
        return __s;
      }

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