[#2212] [#2222] CID26114 and added const to parameter type:

Added bounds-checking
[#2222] Added const
[#2212] CID37619 and CID37556:

Checked for negative return before using return to index array