aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEmilio Jesus Gallego Arias2018-11-09 00:09:10 +0100
committerEmilio Jesus Gallego Arias2018-11-09 00:09:10 +0100
commit31825dc11a8e7fea42702182a3015067b0ed1140 (patch)
tree8431bb53e128cc7219cd4f13d606bb8ab3bec6c1 /lib
parent108c15b51a7d5f647c8681fe7a37c86f0c5a8b9c (diff)
parent0f3dd1243a236dc58ab64e7398024ff1d9d00afa (diff)
Merge PR #8947: Ensure termination of `file_exists_respecting_case`
Diffstat (limited to 'lib')
-rw-r--r--lib/system.ml4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/system.ml b/lib/system.ml
index eec007dcab..a9db95318f 100644
--- a/lib/system.ml
+++ b/lib/system.ml
@@ -83,7 +83,9 @@ let file_exists_respecting_case path f =
let rec aux f =
let bf = Filename.basename f in
let df = Filename.dirname f in
- (String.equal df "." || aux df)
+ (* When [df] is the same as [f], it means that the root of the file system
+ has been reached. There is no point in looking further up. *)
+ (String.equal df "." || String.equal f df || aux df)
&& exists_in_dir_respecting_case (Filename.concat path df) bf
in (!trust_file_cache || Sys.file_exists (Filename.concat path f)) && aux f