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

@@ -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;