hash: Protect against out-of-range input.