Added bounds check on an array index.

Added a bounds check on an array index (line 550).  This only shows up with changes David Dagenhart made on another branch, but should still have the check in the main tree.
Some array indexing was also fixed (line 518), although this line is a safe-guard that I don't expect to ever be invoked anyway (see comment in the line above).  Even so the indexing should be corrected anyway.