Bug 786454 - Protect isReadingListItem against null cursors (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Thu, 15 Nov 2012 14:40:56 +0000
changeset 113382 bb8baf35a2733da29046d89e0f22b5c85cc00767
parent 113381 a5974ecf93c01c4128606d9a183a9799d98c6e12
child 113383 e320680de4fc20e9af4be509e3cf3ee2ce52f8e9
push id23870
push userryanvm@gmail.com
push dateFri, 16 Nov 2012 01:21:36 +0000
treeherdermozilla-central@58ebb638a7ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs786454
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 786454 - Protect isReadingListItem against null cursors (r=mfinkle)
mobile/android/base/db/LocalBrowserDB.java
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -453,28 +453,33 @@ public class LocalBrowserDB implements B
         } catch (NullPointerException e) {
             Log.e(LOGTAG, "NullPointerException in isBookmark");
         }
 
         return (count > 0);
     }
 
     public boolean isReadingListItem(ContentResolver cr, String uri) {
-        Cursor cursor = cr.query(mBookmarksUriWithProfile,
-                                 new String[] { Bookmarks._ID },
-                                 Bookmarks.URL + " = ? AND " +
-                                 Bookmarks.PARENT + " == ?",
-                                 new String[] { uri,
-                                                String.valueOf(Bookmarks.FIXED_READING_LIST_ID) },
-                                 Bookmarks.URL);
+        int count = 0;
+        try {
+            Cursor c = cr.query(mBookmarksUriWithProfile,
+                                new String[] { Bookmarks._ID },
+                                Bookmarks.URL + " = ? AND " +
+                                Bookmarks.PARENT + " == ?",
+                                new String[] { uri,
+                                               String.valueOf(Bookmarks.FIXED_READING_LIST_ID) },
+                                Bookmarks.URL);
 
-        int count = cursor.getCount();
-        cursor.close();
+            count = c.getCount();
+            c.close();
+        } catch (NullPointerException e) {
+            Log.e(LOGTAG, "NullPointerException in isReadingListItem");
+        }
 
-        return (count == 1);
+        return (count > 0);
     }
 
     public String getUrlForKeyword(ContentResolver cr, String keyword) {
         Cursor cursor = cr.query(mBookmarksUriWithProfile,
                                  new String[] { Bookmarks.URL },
                                  Bookmarks.KEYWORD + " = ?",
                                  new String[] { keyword },
                                  null);