fix overflow bugs in parser and scanner: check if we have space before we start writing\!
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@662 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
ea76f86890
commit
ace4b58e5b
@ -9,14 +9,14 @@
|
|||||||
**************************************************************************
|
**************************************************************************
|
||||||
* *
|
* *
|
||||||
* File: mpi.c *
|
* File: mpi.c *
|
||||||
* Last rev: $Date: 2002-10-29 13:58:21 $ *
|
* Last rev: $Date: 2002-10-29 14:02:43 $ *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: Interface to an MPI library *
|
* comments: Interface to an MPI library *
|
||||||
* *
|
* *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpi.c,v 1.10 2002-10-29 13:58:21 stasinos Exp $";
|
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpi.c,v 1.11 2002-10-29 14:02:43 stasinos Exp $";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Yap.h"
|
#include "Yap.h"
|
||||||
@ -237,7 +237,7 @@ mpi_parse(void)
|
|||||||
{
|
{
|
||||||
Term v, t;
|
Term v, t;
|
||||||
TokEntry *tokstart;
|
TokEntry *tokstart;
|
||||||
tr_fr_ptr old_TR;
|
tr_fr_ptr old_TR, TR_before_parse;
|
||||||
|
|
||||||
old_TR = TR;
|
old_TR = TR;
|
||||||
while( TRUE ) {
|
while( TRUE ) {
|
||||||
@ -278,9 +278,11 @@ mpi_parse(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
repeat_cycle:
|
repeat_cycle:
|
||||||
|
TR_before_parse = TR;
|
||||||
if (ErrorMessage || (t = Parse ()) == 0) {
|
if (ErrorMessage || (t = Parse ()) == 0) {
|
||||||
if (ErrorMessage && (strcmp(ErrorMessage,"Stack Overflow") == 0)) {
|
if (ErrorMessage && (strcmp(ErrorMessage,"Stack Overflow") == 0)) {
|
||||||
/* ignore term we just built */
|
/* ignore term we just built */
|
||||||
|
TR = TR_before_parse;
|
||||||
H = old_H;
|
H = old_H;
|
||||||
if (growstack_in_parser(&old_TR, &tokstart, &VarTable)) {
|
if (growstack_in_parser(&old_TR, &tokstart, &VarTable)) {
|
||||||
old_H = H;
|
old_H = H;
|
||||||
@ -295,6 +297,7 @@ mpi_parse(void)
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else if (ParserErrorStyle == CONTINUE_ON_PARSER_ERROR) {
|
} else if (ParserErrorStyle == CONTINUE_ON_PARSER_ERROR) {
|
||||||
ErrorMessage = NULL;
|
ErrorMessage = NULL;
|
||||||
|
TR = TR_before_parse;
|
||||||
/* try again */
|
/* try again */
|
||||||
goto repeat_cycle;
|
goto repeat_cycle;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user