mirror of
https://gcc.gnu.org/git/gcc.git
synced 2025-01-04 01:53:57 +08:00
Fix error handling in recursive_directory_iterator::increment
* src/filesystem/dir.cc (recursive_directory_iterator::increment): Reset state on error. * testsuite/experimental/filesystem/iterators/ recursive_directory_iterator.cc: Check state after increment error. From-SVN: r241552
This commit is contained in:
parent
09844a5f64
commit
b4e7e6bf22
@ -1,5 +1,10 @@
|
||||
2016-10-26 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
* src/filesystem/dir.cc (recursive_directory_iterator::increment):
|
||||
Reset state on error.
|
||||
* testsuite/experimental/filesystem/iterators/
|
||||
recursive_directory_iterator.cc: Check state after increment error.
|
||||
|
||||
PR libstdc++/78111
|
||||
* src/filesystem/ops.cc (canonical): Set error for non-existent path.
|
||||
|
||||
|
@ -343,7 +343,10 @@ fs::recursive_directory_iterator::increment(error_code& ec) noexcept
|
||||
{
|
||||
_Dir dir = open_dir(top.entry.path(), _M_options, &ec);
|
||||
if (ec)
|
||||
return *this;
|
||||
{
|
||||
_M_dirs.reset();
|
||||
return *this;
|
||||
}
|
||||
if (dir.dirp)
|
||||
_M_dirs->push(std::move(dir));
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ test01()
|
||||
VERIFY( iter->path() == p/"d1/d2" );
|
||||
iter.increment(ec); // should fail to recurse into p/d1/d2
|
||||
VERIFY( ec );
|
||||
VERIFY( iter == fs::recursive_directory_iterator() );
|
||||
|
||||
// Test inaccessible sub-directory, skipping permission denied.
|
||||
iter = fs::recursive_directory_iterator(p, opts, ec);
|
||||
|
Loading…
Reference in New Issue
Block a user