From 7bc23f0e80ba19dd9f9ffeddfcc94a8c19c77f51 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Mon, 20 May 2019 21:01:13 +0200 Subject: [PATCH] Is. #761 - just deal with the 'uint' wrap --- src/lexer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lexer.c b/src/lexer.c index ca66aee..ce78a69 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -947,12 +947,15 @@ static void AddByte( Lexer *lexer, tmbchar ch ) { tmbstr buf = NULL; uint allocAmt = lexer->lexlength; + uint prev = allocAmt; /* Is. #761 */ while ( lexer->lexsize + 2 >= allocAmt ) { if ( allocAmt == 0 ) allocAmt = 8192; else allocAmt *= 2; + if (allocAmt < prev) /* Is. #761 - watch for wrap - and */ + TidyPanic(lexer->allocator, "\nPanic: out of internal memory!\nDocument input too big!\n"); } buf = (tmbstr) TidyRealloc( lexer->allocator, lexer->lexbuf, allocAmt ); if ( buf )