Fix a potential buffer overrun from an off-by-one error.