Fixed out-of-bounds reference to dangling pointer