From 03c1edcc90c8252c86fede365c1be2a78edca404 Mon Sep 17 00:00:00 2001 From: vsc Date: Tue, 22 Nov 2005 12:42:39 +0000 Subject: [PATCH] fix parser overflow bug: vars should be reset even when addresses would not change. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1466 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/grow.c | 4 ++++ C/parser.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/C/grow.c b/C/grow.c index 76fb1ff4c..3e5e518a3 100644 --- a/C/grow.c +++ b/C/grow.c @@ -1336,6 +1336,10 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr execute_growstack(size, TRUE, in_parser, old_trp, tksp, vep); } else { YAPEnterCriticalSection(); + if (in_parser) { + TrDiff = LDiff = GDiff = DelayDiff = XDiff = HDiff = 0; + AdjustScannerStacks(tksp, vep); + } Yap_TrailTop += size; YAPLeaveCriticalSection(); } diff --git a/C/parser.c b/C/parser.c index 464742f02..673a7a3b4 100644 --- a/C/parser.c +++ b/C/parser.c @@ -350,9 +350,13 @@ ParseArgs(Atom a, JMPBUFF *FailBuff) else t = Yap_MkApplTerm(Yap_MkFunctor(a, nargs), nargs, p); #endif + if (H > ASP-4096) { + Yap_ErrorMessage = "Stack Overflow"; + return TermNil; + } /* check for possible overflow against local stack */ checkfor((Term) ')', FailBuff); - return (t); + return t; }