diff options
author | Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr> | 2016-03-15 19:56:52 +0100 |
---|---|---|
committer | Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr> | 2016-03-15 19:56:52 +0100 |
commit | 34c467a4e41e20a9bf1318d47fbc09da94c5ad97 (patch) | |
tree | 98c54cb023d6e3e89f4473cab2db4fc17f64886b /lib | |
parent | e5b40d615d0ed9819f6ac8345ed924d8a501172e (diff) |
Fix #4591: Uncaught exception in directory browsing.
We protect Sys.readdir calls againts any nasty exception.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system.ml | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/system.ml b/lib/system.ml index 0ad43a742..36fdf2608 100644 --- a/lib/system.ml +++ b/lib/system.ml @@ -26,6 +26,8 @@ let ok_dirname f = not (String.List.mem f !skipped_dirnames) && (match Unicode.ident_refutation f with None -> true | _ -> false) +let readdir dir = try Sys.readdir dir with any -> [||] + let all_subdirs ~unix_path:root = let l = ref [] in let add f rel = l := (f, rel) :: !l in @@ -38,7 +40,7 @@ let all_subdirs ~unix_path:root = add file newrel; traverse file newrel end) - (Sys.readdir dir) + (readdir dir) in if exists_dir root then traverse root []; List.rev !l @@ -58,7 +60,7 @@ let dirmap = ref StrMap.empty let make_dir_table dir = let filter_dotfiles s f = if f.[0] = '.' then s else StrSet.add f s in - Array.fold_left filter_dotfiles StrSet.empty (Sys.readdir dir) + Array.fold_left filter_dotfiles StrSet.empty (readdir dir) let exists_in_dir_respecting_case dir bf = let contents, cached = |