Skip to content

Commit

Permalink
Bug 1236923 - Check int for overflow. r=peterv
Browse files Browse the repository at this point in the history
  • Loading branch information
EricRahm committed May 21, 2016
1 parent b612e34 commit d0118e6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions parser/expat/lib/xmlparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -6286,6 +6286,9 @@ poolGrow(STRING_POOL *pool)
}
if (pool->blocks && pool->start == pool->blocks->s) {
int blockSize = (int)(pool->end - pool->start)*2;
if (blockSize < 0)
return XML_FALSE;

pool->blocks = (BLOCK *)
pool->mem->realloc_fcn(pool->blocks,
(offsetof(BLOCK, s)
Expand All @@ -6300,10 +6303,17 @@ poolGrow(STRING_POOL *pool)
else {
BLOCK *tem;
int blockSize = (int)(pool->end - pool->start);
if (blockSize < 0)
return XML_FALSE;

if (blockSize < INIT_BLOCK_SIZE)
blockSize = INIT_BLOCK_SIZE;
else
blockSize *= 2;

if (blockSize < 0)
return XML_FALSE;

tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s)
+ blockSize * sizeof(XML_Char));
if (!tem)
Expand Down

0 comments on commit d0118e6

Please sign in to comment.