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 Sebastian Pipping
parent e375ac8478
commit 5c9cc0eed8

View File

@ -6286,7 +6286,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;