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++/12352] New: Exception safety problems in src/localename.cc


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Exception safety problems in src/localename.cc
           Product: gcc
           Version: 3.4
            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

There are numerous exception safety problems in the file src/localename.cc
in the functions

locale::_Impl::_Impl(const _Impl& __imp, size_t __refs)
locale::_Impl::_Impl(const char* __s, size_t __refs) 
void locale::_Impl::_M_replace_categories(const _Impl* __imp, category __cat)
void locale::_Impl::_M_install_facet(const locale::id* __idp, const facet* __fp)

For example, the construct

    try 
      {
      	_M_caches = new const facet*[_M_facets_size];
	for (size_t __i = 0; __i < _M_facets_size; ++__i)
	  _M_caches[__i] = 0;
      }
    catch(...)
      {
	delete [] _M_caches;
	__throw_exception_again;
      }

appears in both constructors. There are several problems with this code.
1) _M_caches is uninitialized before entering the try block, and the
only function that can throw is the call to operator new, so _M_caches is
always uninitialized when the delete[] statement is executed.
2) Resources allocated before entering the try block are leaked.


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