term: fix off-by-one allocation error