Fixed out-of-bounds defect reported by Coverity