Boost logo

Boost :

From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2007-06-22 17:24:55


In operations.cpp, in the dir_itr_first function, there is a static
std::string called dummy_first_name. If the user attempts directory
iteration from the destructor of a global object, it fails because at that
time the static std::string is already destroyed:

BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
dir_itr_first( void *& handle, void *& buffer,
  const std::string & dir, std::string & target,
  file_status &, file_status & )
{
  static const std::string dummy_first_name( "." );
  if ( (handle = ::opendir( dir.c_str() )) == 0 ) return errno;
  target = dummy_first_name;
  std::size_t path_size;
  fs::system_error_type ec = path_max( path_size );
  if ( ec ) return ec;
  dirent de;
  buffer = std::malloc( (sizeof(dirent) - sizeof(de.d_name))
    + path_size + 1 ); // + 1 for "/0"
  return buffer == 0 ? ENOMEM : 0;
}

Emil Dotchevski


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk