Skip to content

Commit 29c9e2c

Browse files
committed
wallet: Do not iterate a directory if having an error while accessing it
This change prevents infinite looping for, for example, system folders on Windows.
1 parent 32692d2 commit 29c9e2c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/wallet/db.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
1818

1919
for (auto it = fs::recursive_directory_iterator(wallet_dir, ec); it != fs::recursive_directory_iterator(); it.increment(ec)) {
2020
if (ec) {
21-
LogPrintf("%s: %s %s\n", __func__, ec.message(), it->path().string());
21+
if (fs::is_directory(*it)) {
22+
it.no_push();
23+
LogPrintf("%s: %s %s -- skipping.\n", __func__, ec.message(), it->path().string());
24+
} else {
25+
LogPrintf("%s: %s %s\n", __func__, ec.message(), it->path().string());
26+
}
2227
continue;
2328
}
2429

0 commit comments

Comments
 (0)