From a57013c3f3ad2ce6f34a22c51339a29769170159 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 4 May 2018 16:56:33 +0700 Subject: [PATCH] Add check for relative path in Local.relative this is to prevent an infinite loop in explode_path --- src/stdune/path.ml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stdune/path.ml b/src/stdune/path.ml index 5931876f..d30e23e3 100644 --- a/src/stdune/path.ml +++ b/src/stdune/path.ml @@ -92,6 +92,12 @@ module Local = struct | i -> String.sub t ~pos:(i + 1) ~len:(len - i - 1) let relative ?error_loc t path = + if not (Filename.is_relative path) then ( + Exn.code_error "Local.relative: received absolute path" + [ "t", Usexp.atom_or_quoted_string t + ; "path", Usexp.atom_or_quoted_string path + ] + ); let rec loop t components = match components with | [] -> Result.Ok t