check for overflow in big strings

This commit is contained in:
Vitor Santos Costa 2012-10-16 08:44:26 +01:00
parent ba866a36e2
commit 610ca06883
2 changed files with 6 additions and 2 deletions

View File

@ -560,6 +560,10 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
t = MkAtomTerm(Yap_LookupWideAtom(p));
else
t = Yap_WideStringToList(p);
if (t == 0L) {
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
NextToken;
}
break;

View File

@ -836,14 +836,14 @@ ch_to_wide(char *base, char *charp)
}
#define add_ch_to_buff(ch) \
if (wcharp) { *wcharp++ = (ch); charp = (char *)wcharp; } \
if (wcharp) { *wcharp++ = (ch); if (wcharp >= (wchar_t *)AuxSp-1024) goto huge_var_error; charp = (char *)wcharp; } \
else { \
if (ch > MAX_ISO_LATIN1 && !wcharp) { \
/* does not fit in ISO-LATIN */ \
wcharp = ch_to_wide(TokImage, charp); \
if (!wcharp) goto huge_var_error; \
*wcharp++ = (ch); charp = (char *)wcharp; \
} else *charp++ = ch; \
} else { if (charp >= (char *)AuxSp-1024) goto huge_var_error; *charp++ = ch; } \
}
TokEntry *