fix off-by-one allocation error