don't crash when number of INVITEMEANS changes

This won't impact shipping code, but if during development I add then
remove a new INVITEMEANS I can crash with AIOOB trying to load by
ordinal. So check first.
This commit is contained in:
Eric House 2020-10-24 13:13:47 -07:00
parent a61db95266
commit 04eeb8f18f

View file

@ -646,11 +646,15 @@ public class DBUtils {
int indxTS = cursor.getColumnIndex( DBHelper.TIMESTAMP ); int indxTS = cursor.getColumnIndex( DBHelper.TIMESTAMP );
int indxTrgt = cursor.getColumnIndex( DBHelper.TARGET ); int indxTrgt = cursor.getColumnIndex( DBHelper.TARGET );
InviteMeans[] values = InviteMeans.values();
while ( cursor.moveToNext() ) { while ( cursor.moveToNext() ) {
InviteMeans means = InviteMeans.values()[cursor.getInt( indxMns )]; int ordinal = cursor.getInt( indxMns );
Date ts = new Date(cursor.getLong(indxTS)); if ( ordinal < values.length ) {
String target = cursor.getString( indxTrgt ); InviteMeans means = values[ordinal];
result.addEntry( means, target, ts ); Date ts = new Date(cursor.getLong(indxTS));
String target = cursor.getString( indxTrgt );
result.addEntry( means, target, ts );
}
} }
} }
cursor.close(); cursor.close();