Fix a memory allocation error: allocate (n+1)*size, not n*(size+1).