Fix off by one problem in StreamPool allocation

This commit is contained in:
richterger 2013-08-07 08:01:33 +02:00 committed by Bernhard Miklautz
parent ceae1b87a5
commit 8d92adca1d

View File

@ -44,7 +44,8 @@ void StreamPool_ShiftUsed(wStreamPool* pool, int index, int count)
}
else if (count < 0)
{
MoveMemory(&pool->uArray[index], &pool->uArray[index - count], (pool->uSize - index) * sizeof(wStream*));
if (pool->uSize - index + count > 0)
MoveMemory(&pool->uArray[index], &pool->uArray[index - count], (pool->uSize - index + count) * sizeof(wStream*));
pool->uSize += count;
}
}
@ -101,7 +102,8 @@ void StreamPool_ShiftAvailable(wStreamPool* pool, int index, int count)
}
else if (count < 0)
{
MoveMemory(&pool->aArray[index], &pool->aArray[index - count], (pool->aSize - index) * sizeof(wStream*));
if (pool->aSize - index + count > 0)
MoveMemory(&pool->aArray[index], &pool->aArray[index - count], (pool->aSize - index + count) * sizeof(wStream*));
pool->aSize += count;
}
}