Fix off-by-one error (discovered by Shao Miller).