Various miscellaneous bounds checking fixes
@pwithnall
Submitted by Philip Withnall Link to original bug (#778943)
Description
None of these fix any real bugs — they’re all to pacify the static analyser, or are in tests or utilities. Still, they can’t hurt.