Correctly handle invalid attribute indexes.