Fix memory leak on array size overflow.