Should fix the case of idx = -1 being rightfully out of bounds. BUG: 447553 (cherry picked from commit 6193824f)