make timeout method in PassphraseCacheService more robust against nullpointers

This commit is contained in:
Vincent Breitmoser
2015-06-30 16:28:55 +02:00
parent 04d7e3f155
commit d26379da3a

View File

@@ -459,11 +459,16 @@ public class PassphraseCacheService extends Service {
* Called when one specific passphrase for keyId timed out * Called when one specific passphrase for keyId timed out
*/ */
private void timeout(long keyId) { private void timeout(long keyId) {
CachedPassphrase cPass = mPassphraseCache.get(keyId); CachedPassphrase cPass = mPassphraseCache.get(keyId);
// clean internal char[] from memory! if (cPass != null) {
cPass.getPassphrase().removeFromMemory(); if (cPass.getPassphrase() != null) {
// remove passphrase object // clean internal char[] from memory!
mPassphraseCache.remove(keyId); cPass.getPassphrase().removeFromMemory();
}
// remove passphrase object
mPassphraseCache.remove(keyId);
}
Log.d(Constants.TAG, "PassphraseCacheService Timeout of keyId " + keyId + ", removed from memory!"); Log.d(Constants.TAG, "PassphraseCacheService Timeout of keyId " + keyId + ", removed from memory!");