From 09d988b144cc4d3e3c77dd193aaacd4de0ba1e1e Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Sun, 30 Oct 2016 23:15:24 +0100 Subject: [PATCH] fix crash in load map dialog when you have no permissions on /media --- src/desktop/paths.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/desktop/paths.cpp b/src/desktop/paths.cpp index 5cf622e746a1..627a7a6f6d20 100644 --- a/src/desktop/paths.cpp +++ b/src/desktop/paths.cpp @@ -109,9 +109,16 @@ void enumerate_storage_devices(std::vector& res) for(const auto& mnt : candidates) { bsys::error_code e; - if(bfs::is_directory(mnt, e) && !bfs::is_empty(mnt, e) && !e) { - DBG_DU << "enumerate_mount_parents(): " << mnt << " appears to be a non-empty dir\n"; - res.push_back({mnt, "", mnt}); + try { + if(bfs::is_directory(mnt, e) && !bfs::is_empty(mnt, e) && !e) { + DBG_DU << "enumerate_mount_parents(): " << mnt << " appears to be a non-empty dir\n"; + res.push_back({mnt, "", mnt}); + } + } + catch(...) { + //bool is_empty(const path& p, system::error_code& ec) might throw. + //For example if you have no permission on that directory. Don't list the file in that case. + DBG_DU << "caught exception in enumerate_storage_devices\n"; } }