From f53caf1f863f140de1c1af51906e658c9fb7d7d6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 20 Feb 2019 11:11:12 -0300 Subject: Avoid stack overflow when handling nested captures The C code uses recursion to handle nested captures, so a too deep nesting could create a stack overflow. The fix limits the handling of nested captures to 'MAXRECLEVEL' (default is 200 levels). --- test.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test.lua') diff --git a/test.lua b/test.lua index 476da0a..8f9f574 100755 --- a/test.lua +++ b/test.lua @@ -424,6 +424,16 @@ do end +do + -- nesting of captures too deep + local p = m.C(1) + for i = 1, 300 do + p = m.Ct(p) + end + checkerr("too deep", p.match, p, "x") +end + + -- tests for non-pattern as arguments to pattern functions p = { ('a' * m.V(1))^-1 } * m.P'b' * { 'a' * m.V(2); m.V(1)^-1 } -- cgit v1.2.3-55-g6feb