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 indxTrgt = cursor.getColumnIndex( DBHelper.TARGET );
InviteMeans[] values = InviteMeans.values();
while ( cursor.moveToNext() ) {
InviteMeans means = InviteMeans.values()[cursor.getInt( indxMns )];
Date ts = new Date(cursor.getLong(indxTS));
String target = cursor.getString( indxTrgt );
result.addEntry( means, target, ts );
int ordinal = cursor.getInt( indxMns );
if ( ordinal < values.length ) {
InviteMeans means = values[ordinal];
Date ts = new Date(cursor.getLong(indxTS));
String target = cursor.getString( indxTrgt );
result.addEntry( means, target, ts );
}
}
}
cursor.close();