fix memory overflow

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1203 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-12-07 16:54:58 +00:00
parent f70af77e0c
commit db9a865263
2 changed files with 13 additions and 4 deletions

View File

@ -11,8 +11,13 @@
* File: amasm.c *
* comments: abstract machine assembler *
* *
* Last rev: $Date: 2004-12-05 05:01:23 $ *
* Last rev: $Date: 2004-12-07 16:54:57 $ *
* $Log: not supported by cvs2svn $
* Revision 1.67 2004/12/05 05:01:23 vsc
* try to reduce overheads when running with goal expansion enabled.
* CLPBN fixes
* Handle overflows when allocating big clauses properly.
*
* Revision 1.66 2004/11/19 22:08:41 vsc
* replace SYSTEM_ERROR by out OUT_OF_WHATEVER_ERROR whenever appropriate.
*
@ -2971,7 +2976,6 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip)
case OUT_OF_AUXSPACE_ERROR:
ARG1 = *tp;
if (!Yap_ExpandPreAllocCodeSpace(Yap_Error_Size, (void *)cip)) {
H = (CELL *)H[-1];
return NULL;
}
Yap_Error_TYPE = YAP_NO_ERROR;
@ -2981,7 +2985,6 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip)
/* don't just return NULL */
ARG1 = *tp;
if (!Yap_growheap(TRUE, size, cip)) {
H = (CELL *)H[-1];
return NULL;
}
Yap_Error_TYPE = YAP_NO_ERROR;

View File

@ -1449,6 +1449,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
return CreateDBRefForAtom(Tm, p, InFlag, dbg);
}
}
/* next, let's process a compound term */
{
DBTerm *ppt, *ppt0;
DBRef pp, pp0;
@ -1459,7 +1460,6 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
#endif
dbg->tofref = TmpRefBase;
/* compound term */
if (p == NULL) {
ADDR ptr = Yap_PreAllocCodeSpace();
@ -1469,6 +1469,12 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
pp0 = (DBRef)Yap_PreAllocCodeSpace();
ppt0 = &(pp0->DBT);
}
if ((ADDR)ppt0 >= (ADDR)AuxSp-1024) {
Yap_Error_Size = (UInt)(extra_size+sizeof(ppt0));
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
return NULL;
}
ntp0 = ppt0->Contents;
#ifdef IDB_LINK_TABLE
dbg->lr = dbg->LinkAr = (link_entry *)TR;