Avoid undefined behavior when computing larger blockSize. The compiler might reason that (end - start)*2 is negative only if (end - start) is negative, see https://godbolt.org/g/wVEoTM

This commit is contained in:
Pascal Cuoq 2016-05-15 19:11:55 +02:00 committed by Vadim Zeitlin
parent b6bc23c9b4
commit 6a3374989c

View File

@ -6264,7 +6264,7 @@ poolGrow(STRING_POOL *pool)
}
if (pool->blocks && pool->start == pool->blocks->s) {
BLOCK *temp;
int blockSize = (int)(pool->end - pool->start)*2;
int blockSize = (int)((unsigned)(pool->end - pool->start)*2U);
if (blockSize < 0)
return XML_FALSE;