Add check for relative path in Local.relative

this is to prevent an infinite loop in explode_path
This commit is contained in:
Rudi Grinberg 2018-05-04 16:56:33 +07:00
parent f4a5413c46
commit a57013c3f3
1 changed files with 6 additions and 0 deletions

View File

@ -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