Revert 180817 because 180816 was reverted.
Fix a use after free.  RI is freed before the call to getDebugLoc().  To
prevent this, capture the location before RI is freed.