coverity: fixed out of bounds read-write