OSDN Git Service

Handle unexpected null cursor and don't forget to close it.
authorAmith Yamasani <yamasani@google.com>
Tue, 4 Oct 2011 22:00:21 +0000 (15:00 -0700)
committerAmith Yamasani <yamasani@google.com>
Tue, 4 Oct 2011 22:00:21 +0000 (15:00 -0700)
Bug: 5406071
Change-Id: Ia40cf7e5a3e32d6f364e787ee66580c685507571

src/com/android/settings/SoundSettings.java

index 8b7cd37..f73460b 100644 (file)
@@ -351,8 +351,11 @@ public class SoundSettings extends SettingsPreferenceFragment implements
             try {
                 Cursor cursor = context.getContentResolver().query(ringtoneUri,
                         new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);
-                if (cursor.moveToFirst()) {
-                    summary = cursor.getString(0);
+                if (cursor != null) {
+                    if (cursor.moveToFirst()) {
+                        summary = cursor.getString(0);
+                    }
+                    cursor.close();
                 }
             } catch (SQLiteException sqle) {
                 // Unknown title for the ringtone