Fix shift in buffer size calculation which resulted in too large allocs.

Fixes issue 426.