Fix out of bound array element access

GitHub: fix #158

Reported by dcb314. Thanks!!!