mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 04:22:18 -05:00
fix a couple of resource leaks (#1351)
This commit is contained in:
parent
300fd8e0f2
commit
5895385153
@ -303,10 +303,13 @@ public class ContactHelper {
|
|||||||
Cursor contactMasterKey = context.getContentResolver().query(contactUri,
|
Cursor contactMasterKey = context.getContentResolver().query(contactUri,
|
||||||
new String[]{ContactsContract.Data.DATA2}, null, null, null);
|
new String[]{ContactsContract.Data.DATA2}, null, null, null);
|
||||||
if (contactMasterKey != null) {
|
if (contactMasterKey != null) {
|
||||||
if (contactMasterKey.moveToNext()) {
|
try {
|
||||||
return KeychainContract.KeyRings.buildGenericKeyRingUri(contactMasterKey.getLong(0));
|
if (contactMasterKey.moveToNext()) {
|
||||||
|
return KeychainContract.KeyRings.buildGenericKeyRingUri(contactMasterKey.getLong(0));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
contactMasterKey.close();
|
||||||
}
|
}
|
||||||
contactMasterKey.close();
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -537,7 +540,7 @@ public class ContactHelper {
|
|||||||
KEYS_TO_CONTACT_PROJECTION,
|
KEYS_TO_CONTACT_PROJECTION,
|
||||||
KeychainContract.KeyRings.HAS_ANY_SECRET + "!=0",
|
KeychainContract.KeyRings.HAS_ANY_SECRET + "!=0",
|
||||||
null, null);
|
null, null);
|
||||||
if (cursor != null) {
|
if (cursor != null) try {
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
||||||
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
|
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
|
||||||
@ -565,6 +568,8 @@ public class ContactHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
cursor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (long masterKeyId : keysToDelete) {
|
for (long masterKeyId : keysToDelete) {
|
||||||
|
@ -66,21 +66,24 @@ public class ParcelableFileCache<E extends Parcelable> {
|
|||||||
|
|
||||||
File tempFile = new File(mContext.getCacheDir(), mFilename);
|
File tempFile = new File(mContext.getCacheDir(), mFilename);
|
||||||
|
|
||||||
|
|
||||||
DataOutputStream oos = new DataOutputStream(new FileOutputStream(tempFile));
|
DataOutputStream oos = new DataOutputStream(new FileOutputStream(tempFile));
|
||||||
|
|
||||||
oos.writeInt(numEntries);
|
try {
|
||||||
|
oos.writeInt(numEntries);
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Parcel p = Parcel.obtain(); // creating empty parcel object
|
Parcel p = Parcel.obtain(); // creating empty parcel object
|
||||||
p.writeParcelable(it.next(), 0); // saving bundle as parcel
|
p.writeParcelable(it.next(), 0); // saving bundle as parcel
|
||||||
byte[] buf = p.marshall();
|
byte[] buf = p.marshall();
|
||||||
oos.writeInt(buf.length);
|
oos.writeInt(buf.length);
|
||||||
oos.write(buf);
|
oos.write(buf);
|
||||||
p.recycle();
|
p.recycle();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
oos.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
oos.close();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user