diff --git a/C/arrays.c b/C/arrays.c index b22f3342f..cf79f998e 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -158,8 +158,11 @@ AccessNamedArray(Atom a, Int indx) if (ArrayIsDynamic(pp)) { Term out; READ_LOCK(pp->ArRWLock); - if (IsVarTerm(pp->ValueOfVE)) { + if (IsVarTerm(pp->ValueOfVE) || + pp->ArrayEArity <= indx || + indx < 0) { READ_UNLOCK(pp->ArRWLock); + P = (yamop *)FAILCODE; return(MkAtomTerm(AtomFoundVar)); } out = RepAppl(pp->ValueOfVE)[indx+1]; @@ -173,7 +176,7 @@ AccessNamedArray(Atom a, Int indx) /* Error(DOMAIN_ERROR_ARRAY_OVERFLOW, MkIntegerTerm(indx), "access_array");*/ READ_UNLOCK(ptr->ArRWLock); P = (yamop *)FAILCODE; - return(TermNil); + return(MkAtomTerm(AtomFoundVar)); } switch (ptr->ArrayType) { @@ -302,7 +305,7 @@ p_access_array(void) if (IsNonVarTerm(t)) { if (IsApplTerm(t)) { - if (indx >= ArityOfFunctor(FunctorOfTerm(t))) { + if (indx >= ArityOfFunctor(FunctorOfTerm(t)) || indx < 0) { /* Error(DOMAIN_ERROR_ARRAY_OVERFLOW, MkIntegerTerm(indx), "access_array");*/ P = (yamop *)FAILCODE; return(FALSE); diff --git a/C/tracer.c b/C/tracer.c index fd16b954d..72c48835b 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -112,7 +112,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) /* extern int gc_calls; */ vsc_count++; - if (vsc_count < 3829100) return; + /* if (vsc_count < 3829100) return;*/ /* if (vsc_count == 4376) { printf("Here I go\n");