diff --git a/src/system.c b/src/system.c index 9b5a8dc..a8e21bd 100644 --- a/src/system.c +++ b/src/system.c @@ -453,12 +453,15 @@ run_localize (const System sys, const int rid, Termlist fromlist, Term t; t = substlist->term; - if (t->subst != NULL) + if (t != NULL) { - t->subst = termLocal (t->subst, fromlist, tolist); - sys->runs[rid].substitutions = - termlistAdd (sys->runs[rid].substitutions, t); - } + if (t->subst != NULL) + { + t->subst = termLocal (t->subst, fromlist, tolist); + sys->runs[rid].substitutions = + termlistAdd (sys->runs[rid].substitutions, t); + } + } substlist = substlist->next; } } diff --git a/src/termlist.c b/src/termlist.c index b56df27..0f70edc 100644 --- a/src/termlist.c +++ b/src/termlist.c @@ -629,14 +629,18 @@ termlistLength (Termlist tl) *\sa termlistLocal() */ Term -termLocal (const Term t, Termlist fromlist, Termlist tolist) +termLocal (const Term tPre, Termlist fromlist, Termlist tolist) { - if (t == NULL) + Term t; + + if (tPre == NULL) return NULL; + t = deVar(tPre); + if (realTermLeaf (t)) { - while (fromlist != NULL && tolist != NULL) + while ((fromlist != NULL) && (tolist != NULL)) { if (isTermEqual (fromlist->term, t)) { @@ -650,7 +654,9 @@ termLocal (const Term t, Termlist fromlist, Termlist tolist) } else { - Term newt = termNodeDuplicate (t); + Term newt; + + newt = termNodeDuplicate (t); if (realTermTuple (t)) { TermOp1 (newt) = termLocal (TermOp1 (t), fromlist, tolist); @@ -658,8 +664,11 @@ termLocal (const Term t, Termlist fromlist, Termlist tolist) } else { - TermOp (newt) = termLocal (TermOp (t), fromlist, tolist); - TermKey (newt) = termLocal (TermKey (t), fromlist, tolist); + if (realTermEncrypt (t)) + { + TermOp (newt) = termLocal (TermOp (t), fromlist, tolist); + TermKey (newt) = termLocal (TermKey (t), fromlist, tolist); + } } return newt; }