Fix possible off-by-one overflow.