diff -Nru lua-lpeg-1.0.0/debian/changelog lua-lpeg-1.0.0/debian/changelog --- lua-lpeg-1.0.0/debian/changelog 2018-02-23 12:39:59.000000000 +0100 +++ lua-lpeg-1.0.0/debian/changelog 2019-10-02 17:49:19.000000000 +0200 @@ -1,3 +1,10 @@ +lua-lpeg (1.0.0-2ubuntu1) focal; urgency=medium + + * d/p/stop-hascaptures-recursion.patch: Fix infinite recursion in + hascaptures() + + -- Victor Tapia Wed, 02 Oct 2019 17:49:19 +0200 + lua-lpeg (1.0.0-2) unstable; urgency=medium * Team upload. diff -Nru lua-lpeg-1.0.0/debian/control lua-lpeg-1.0.0/debian/control --- lua-lpeg-1.0.0/debian/control 2018-02-23 12:39:59.000000000 +0100 +++ lua-lpeg-1.0.0/debian/control 2019-10-02 17:49:19.000000000 +0200 @@ -1,7 +1,8 @@ Source: lua-lpeg Section: interpreters Priority: optional -Maintainer: Enrico Tassi +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Enrico Tassi Build-Depends: dh-lua, debhelper (>= 8.0.0) Standards-Version: 3.9.6 Homepage: http://www.inf.puc-rio.br/~roberto/lpeg.html diff -Nru lua-lpeg-1.0.0/debian/patches/series lua-lpeg-1.0.0/debian/patches/series --- lua-lpeg-1.0.0/debian/patches/series 2018-02-23 12:39:59.000000000 +0100 +++ lua-lpeg-1.0.0/debian/patches/series 2019-10-02 17:49:19.000000000 +0200 @@ -0,0 +1 @@ +stop-hascaptures-recursion.patch diff -Nru lua-lpeg-1.0.0/debian/patches/stop-hascaptures-recursion.patch lua-lpeg-1.0.0/debian/patches/stop-hascaptures-recursion.patch --- lua-lpeg-1.0.0/debian/patches/stop-hascaptures-recursion.patch 1970-01-01 01:00:00.000000000 +0100 +++ lua-lpeg-1.0.0/debian/patches/stop-hascaptures-recursion.patch 2019-10-02 17:49:19.000000000 +0200 @@ -0,0 +1,59 @@ +From: Victor Tapia +Date: Tue, 8 Oct 2014 18:44:17 +0200 +Origin: backport, http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.0.1.tar.gz +Description: Stop infinite recursion in hascaptures() + Stop recursion in TCall nodes and control that TRule nodes do not follow sib2 + +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+bug/1580385 + +--- +--- a/lpcode.c ++++ b/lpcode.c +@@ -126,6 +126,27 @@ + + + /* ++** Visit a TCall node taking care to stop recursion. If node not yet ++** visited, return 'f(sib2(tree))', otherwise return 'def' (default ++** value) ++*/ ++static int callrecursive (TTree *tree, int f (TTree *t), int def) { ++ int key = tree->key; ++ assert(tree->tag == TCall); ++ assert(sib2(tree)->tag == TRule); ++ if (key == 0) /* node already visited? */ ++ return def; /* return default value */ ++ else { /* first visit */ ++ int result; ++ tree->key = 0; /* mark call as already visited */ ++ result = f(sib2(tree)); /* go to called rule */ ++ tree->key = key; /* restore tree */ ++ return result; ++ } ++} ++ ++ ++/* + ** Check whether a pattern tree has captures + */ + int hascaptures (TTree *tree) { +@@ -134,14 +155,17 @@ + case TCapture: case TRunTime: + return 1; + case TCall: +- tree = sib2(tree); goto tailcall; /* return hascaptures(sib2(tree)); */ ++ return callrecursive(tree, hascaptures, 0); ++ case TRule: /* do not follow siblings */ ++ tree = sib1(tree); goto tailcall; + case TOpenCall: assert(0); + default: { + switch (numsiblings[tree->tag]) { + case 1: /* return hascaptures(sib1(tree)); */ + tree = sib1(tree); goto tailcall; + case 2: +- if (hascaptures(sib1(tree))) return 1; ++ if (hascaptures(sib1(tree))) ++ return 1; + /* else return hascaptures(sib2(tree)); */ + tree = sib2(tree); goto tailcall; + default: assert(numsiblings[tree->tag] == 0); return 0;