From fdef09f11c904462f3e790a079dd681bc128b7b8 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Fri, 28 Oct 2016 22:24:30 +0200 Subject: Wallet API: make sure path exists before searching for wallets --- src/wallet/api/wallet_manager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp index aa99476ee..b8500aae3 100644 --- a/src/wallet/api/wallet_manager.cpp +++ b/src/wallet/api/wallet_manager.cpp @@ -88,10 +88,13 @@ bool WalletManagerImpl::walletExists(const std::string &path) std::vector WalletManagerImpl::findWallets(const std::string &path) { std::vector result; + boost::filesystem::path work_dir(path); + // return empty result if path doesn't exist + if(!boost::filesystem::is_directory(path)){ + return result; + } const boost::regex wallet_rx("(.*)\\.(keys)$"); // searching for .keys files boost::filesystem::recursive_directory_iterator end_itr; // Default ctor yields past-the-end - boost::filesystem::path work_dir(path); - for (boost::filesystem::recursive_directory_iterator itr(path); itr != end_itr; ++itr) { // Skip if not a file if (!boost::filesystem::is_regular_file(itr->status())) -- cgit v1.2.3