Out of range check fix (spotted by Coverity: CID 1100931)