From b1e5899d2ff7383c1e4cf6acd10e2e6eeabde832 Mon Sep 17 00:00:00 2001 From: Anil Madhavapeddy Date: Wed, 27 May 2026 11:08:44 +0100 Subject: [PATCH] Raise an invalid_argument if we encounter a pattern match exhaustion The checker invokes `String.get path i` without checking bounds, which then raises. Instead, raise Invalid_argument in these cases except for index_from_opt which returns an option. --- src/glob.ml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/glob.ml b/src/glob.ml index 19ce3df..17539a3 100644 --- a/src/glob.ml +++ b/src/glob.ml @@ -197,6 +197,9 @@ let matches ?options glob path = ignore options; let rec matches i path = function | [] -> Int.equal (String.length path) i + | (Dir_sep | String _ | Question | Range _ | Complement _) :: _ + when i >= String.length path -> + false | Dir_sep :: rest -> let b = Char.equal (String.get path i) glob.dir_sep in b && matches (i + 1) path rest -- 2.51.2