From 89a239964bcdb2cf02e89c38e70c65128d0b4ee4 Mon Sep 17 00:00:00 2001
From: Patrick Baudin <patrick.baudin@cea.fr>
Date: Tue, 25 Jan 2022 08:49:14 +0100
Subject: [PATCH] [ptests] prevents infinite recursion in macro expansion

---
 ptests/ptests.ml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ptests/ptests.ml b/ptests/ptests.ml
index 2f839e6589a..021f6e1c972 100644
--- a/ptests/ptests.ml
+++ b/ptests/ptests.ml
@@ -785,7 +785,11 @@ struct
       let has_frama_c_exe = ref false in
       if !verbosity >= 4 then lock_printf "%% Expand: %s@." s;
       if !verbosity >= 5 then print_macros macros;
+      let nb_loops = ref 0 in
       let rec aux s =
+        if !nb_loops > 100 then
+          fail "Possible infinite recursion in macro expands"
+        else incr nb_loops ;
         let expand_macro = function
           | Str.Text s -> s
           | Str.Delim s ->
-- 
GitLab