Bug 765486 - Protect isBookmark() against NPE. r=lucasr
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 20 Jun 2012 17:56:02 -0700
changeset 97282 f886c5bfd27328309fb0aeef0bd261304bcee20a
parent 97281 fed89ccfe0c25e5dd41cf111bfc205d799a9b026
child 97283 de6e7c9a28c0c6691c755d628ab872f77b67d234
push id10963
push usermleibovic@mozilla.com
push dateThu, 21 Jun 2012 16:10:55 +0000
treeherdermozilla-inbound@8d73102a64e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs765486
milestone16.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 765486 - Protect isBookmark() against NPE. r=lucasr
mobile/android/base/db/LocalBrowserDB.java
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -373,26 +373,30 @@ public class LocalBrowserDB implements B
 
         // Cache result for future queries
         mReadingListItemsExist = (count > 0);
         return mReadingListItemsExist;
     }
 
     public boolean isBookmark(ContentResolver cr, String uri) {
         // This method is about normal bookmarks, not the Reading List
-        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 = cursor.getCount();
-        cursor.close();
+        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);
+            count = c.getCount();
+            c.close();
+        } catch (NullPointerException e) {
+            Log.e(LOGTAG, "NullPointerException in isBookmark for " + uri);
+        }
 
         return (count == 1);
     }
 
     public boolean isReadingListItem(ContentResolver cr, String uri) {
         Cursor cursor = cr.query(mBookmarksUriWithProfile,
                                  new String[] { Bookmarks._ID },
                                  Bookmarks.URL + " = ? AND " +