From 8569aacfe5fe55e55a84abee19ea474f642ae523 Mon Sep 17 00:00:00 2001 From: Costa Vitor Date: Wed, 15 Jul 2009 14:26:56 -0500 Subject: [PATCH] check for very long wchar_t strings when scanning (obs from Jan Wielemaker). --- C/scanner.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/C/scanner.c b/C/scanner.c index a8b4c326b..9deddaf68 100644 --- a/C/scanner.c +++ b/C/scanner.c @@ -1003,7 +1003,11 @@ Yap_tokenizer(int inp_stream, Term *tposp) wcharp = NULL; while (TRUE) { - if (charp + 1024 > (char *)AuxSp) { + if (wcharp && wcharp + 1024 > (wchar_t *)AuxSp) { + Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + Yap_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)"; + break; + } else if (charp + 1024 > (char *)AuxSp) { Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR; Yap_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)"; break;