From 19fcb48e72c30849e7b21a302419c9ffb58a4c96 Mon Sep 17 00:00:00 2001 From: Jan Henning Date: Wed, 23 Aug 2017 21:13:35 +0200 Subject: [PATCH] Bug 1390140 - Account for bookmark ID being when populating BrowserSearch's HomeContextMenuInfo. r=Grisha The combined history view returns a bookmark ID of for items that aren't a bookmark. Calling cursor.getInt() silently turns this into an ID of 0, which doesn't play well with the rest of our code that assumes that the bookmark ID for items that aren't in fact bookmarks is -1. When pressing "Remove" on a search history result, this means that we then end up trying to remove bookmark 0, i.e. the root "bookmark". Luckily this attempt doesn't succeed, but unfortunately still manages to crash the browser along the way. MozReview-Commit-ID: FZk4cI2EDAE --HG-- extra : rebase_source : c35a8c3eabeb8607392e073df0d697585e78c64c --- .../base/java/org/mozilla/gecko/home/BrowserSearch.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mobile/android/base/java/org/mozilla/gecko/home/BrowserSearch.java b/mobile/android/base/java/org/mozilla/gecko/home/BrowserSearch.java index 3e6181150031..e25d1067a995 100644 --- a/mobile/android/base/java/org/mozilla/gecko/home/BrowserSearch.java +++ b/mobile/android/base/java/org/mozilla/gecko/home/BrowserSearch.java @@ -377,7 +377,8 @@ public class BrowserSearch extends HomeFragment info.url = cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.Combined.URL)); info.title = cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.Combined.TITLE)); - int bookmarkId = cursor.getInt(cursor.getColumnIndexOrThrow(BrowserContract.Combined.BOOKMARK_ID)); + final int bookmarkColumn = cursor.getColumnIndexOrThrow(BrowserContract.Combined.BOOKMARK_ID); + int bookmarkId = cursor.isNull(bookmarkColumn) ? -1 : cursor.getInt(bookmarkColumn); info.bookmarkId = bookmarkId; int historyId = cursor.getInt(cursor.getColumnIndexOrThrow(BrowserContract.Combined.HISTORY_ID));