Merge pull request #830 from htacg/issue-761-1

Is. #761 - just deal with the 'uint' wrap
This commit is contained in:
Geoff McLane 2020-10-02 17:16:45 +02:00 committed by GitHub
commit 3dafcf1341
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 )