overflow in string
This commit is contained in:
parent
ccd7916d31
commit
ce61f810c2
36
C/dbase.c
36
C/dbase.c
@ -1396,12 +1396,14 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
||||
SMALLUNSGN flag;
|
||||
int NOfLinks = 0;
|
||||
/* place DBRefs in ConsultStack */
|
||||
DBRef *TmpRefBase = (DBRef *)LOCAL_TrailTop;
|
||||
DBRef *TmpRefBase;
|
||||
CELL *CodeAbs; /* how much code did we find */
|
||||
int vars_found = FALSE;
|
||||
yap_error_number oerr = LOCAL_Error_TYPE;
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
|
||||
retry_record:
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
TmpRefBase = (DBRef *)LOCAL_TrailTop;
|
||||
if (p == NULL) {
|
||||
if (IsVarTerm(Tm)) {
|
||||
#ifdef COROUTINING
|
||||
@ -1475,7 +1477,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
||||
/* attachment */
|
||||
if (IsVarTerm(Tm)) {
|
||||
tt = (CELL)(ppt0->Contents);
|
||||
ntp = MkDBTerm(VarOfTerm(Tm), VarOfTerm(Tm), ntp0, ntp0 + 1, ntp0 - 1,
|
||||
ntp = MkDBTerm(VarOfTerm(Tm), VarOfTerm(Tm), ntp0, ntp0 + 1, ntp0 - 1,
|
||||
&attachments, &vars_found, dbg);
|
||||
if (ntp == NULL) {
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
@ -1500,7 +1502,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
||||
} else {
|
||||
unsigned int arity;
|
||||
Functor fun;
|
||||
|
||||
vars_found = true;
|
||||
tt = AbsAppl(ppt0->Contents);
|
||||
/* we need to store the functor manually */
|
||||
fun = FunctorOfTerm(Tm);
|
||||
@ -1510,13 +1512,37 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
|
||||
ntp = copy_double(ntp0, RepAppl(Tm));
|
||||
break;
|
||||
case (CELL)FunctorString:
|
||||
ntp = copy_string(ntp0, RepAppl(Tm));
|
||||
{
|
||||
UInt sz = 1024+sizeof(CELL)*(3 + RepAppl(Tm)[1]);
|
||||
if (sz >
|
||||
(char*)AuxSp-(char*)ppt0) {
|
||||
LOCAL_Error_Size = sz;
|
||||
if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) {
|
||||
Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, TermNil, LOCAL_ErrorMessage);
|
||||
return NULL;
|
||||
}
|
||||
goto retry_record;
|
||||
}
|
||||
}
|
||||
ntp = copy_string(ntp0, RepAppl(Tm));
|
||||
break;
|
||||
case (CELL)FunctorDBRef:
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return CreateDBWithDBRef(Tm, p, dbg);
|
||||
#ifdef USE_GMP
|
||||
case (CELL)FunctorBigInt:
|
||||
{
|
||||
UInt sz = 1024+sizeof(CELL)*Yap_SizeOfBigInt(Tm);
|
||||
if (sz >
|
||||
(char*)AuxSp-(char*)ppt0) {
|
||||
LOCAL_Error_Size = sizeof(CELL)*(3 + RepAppl(Tm)[1]);
|
||||
if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) {
|
||||
Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, TermNil, LOCAL_ErrorMessage);
|
||||
return NULL;
|
||||
}
|
||||
goto retry_record;
|
||||
}
|
||||
}
|
||||
ntp = copy_big_int(ntp0, RepAppl(Tm));
|
||||
break;
|
||||
#endif
|
||||
|
@ -1180,13 +1180,15 @@ Term Yap_tokRep(void *tokptre) {
|
||||
case Name_tok:
|
||||
if (!info) {
|
||||
info = TermNil;
|
||||
} else {
|
||||
info = MkAtomTerm((Atom)info);
|
||||
}
|
||||
return Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, &info);
|
||||
case QuasiQuotes_tok:
|
||||
info = MkAtomTerm(Yap_LookupAtom("<QQ>"));
|
||||
return Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, &info);
|
||||
case Number_tok:
|
||||
return Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, &info);
|
||||
return Yap_MkApplTerm(Yap_MkFunctor(AtomNumber, 1), 1, &info);
|
||||
break;
|
||||
case Var_tok: {
|
||||
Term t[2];
|
||||
|
@ -211,7 +211,13 @@ extern struct various_codes *Yap_heap_regs;
|
||||
*/
|
||||
|
||||
static inline yamop *gc_P(yamop *p, yamop *cp) {
|
||||
return (p && p->opc == EXECUTE_CPRED_OPCODE ? cp : p);
|
||||
yamop *n= (p && p->opc == EXECUTE_CPRED_OPCODE ? cp : p);
|
||||
if (p->opc == Yap_opcode(_try_c) ||
|
||||
p->opc == Yap_opcode(_try_userc) ||
|
||||
p->opc == Yap_opcode(_retry_c) ||
|
||||
p->opc == Yap_opcode(_retry_userc))
|
||||
return cp;
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user