ContactsContract: Fix null pointer exception in openContactPhotoInputStream()

Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2009-08-24 18:12:51 -07:00
parent ec9fe4672a
commit 7d6eb9a4b4

View File

@@ -343,7 +343,7 @@ public final class ContactsContract {
Cursor cursor = cr.query(photoUri,
new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
try {
if (!cursor.moveToNext()) {
if (cursor == null || !cursor.moveToNext()) {
return null;
}
byte[] data = cursor.getBlob(0);
@@ -352,7 +352,9 @@ public final class ContactsContract {
}
return new ByteArrayInputStream(data);
} finally {
cursor.close();
if (cursor != null) {
cursor.close();
}
}
}
}