deal with illegal values for device type (#434)

This commit is contained in:
m2049r 2018-10-10 21:11:59 +02:00 committed by GitHub
parent 3cf84c599d
commit 8c01ec36e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -183,7 +183,11 @@ public class WalletManager {
public Wallet.Device queryWalletDevice(String keys_file_name, String password) {
int device = queryWalletDeviceJ(keys_file_name, password);
return Wallet.Device.values()[device + 1]; // mapping is monero+1=android
Wallet.Device[] types = Wallet.Device.values();
// mapping is monero+1=android
if ((device < 0) || (device > types.length - 2))
device = -1;
return types[device + 1];
}
private native int queryWalletDeviceJ(String keys_file_name, String password);