From 95844035aa60a1fcfecb16bb4fa4e7c50ac12e24 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 25 Aug 2017 01:08:05 -0400 Subject: [PATCH] Fix out of bounds access when tokenising String_with_vars When the current character is '$' we peek at the next character. But we first need to make sure that there is a next character. --- src/string_with_vars.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string_with_vars.ml b/src/string_with_vars.ml index b3e635b8..0ce1353d 100644 --- a/src/string_with_vars.ml +++ b/src/string_with_vars.ml @@ -28,7 +28,7 @@ module Token = struct match s.[j] with | '}' -> cons_str i j (Close Braces :: loop (j + 1) (j + 1)) | ')' -> cons_str i j (Close Parens :: loop (j + 1) (j + 1)) - | '$' -> begin + | '$' when j + 1 < len -> begin match s.[j + 1] with | '{' -> cons_str i j (Open Braces :: loop (j + 2) (j + 2)) | '(' -> cons_str i j (Open Parens :: loop (j + 2) (j + 2))