From 1f1dae79e6b996099736c0ab41a1a080192412d7 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 7 Mar 2017 13:17:37 +0100 Subject: [PATCH] Fixed cursor empty checks. --- .../freerdp/freerdpcore/services/BookmarkBaseGateway.java | 6 +++--- .../freerdp/freerdpcore/services/ManualBookmarkGateway.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java index 45ec0c5ee..f6d866a3f 100644 --- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java +++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java @@ -157,7 +157,7 @@ public abstract class BookmarkBaseGateway { Log.e(TAG, "More than one bookmark with the same label found!"); BookmarkBase bookmark = null; - if (cursor.moveToFirst()) + if (cursor.moveToFirst() && (cursor.getCount() > 0)) bookmark = getBookmarkFromCursor(cursor); cursor.close(); @@ -168,7 +168,7 @@ public abstract class BookmarkBaseGateway { Cursor cursor = queryBookmarks("label LIKE '%" + pattern + "%'", "label"); ArrayList bookmarks = new ArrayList(cursor.getCount()); - if (cursor.moveToFirst()) { + if (cursor.moveToFirst() && (cursor.getCount() > 0)) { do { bookmarks.add(getBookmarkFromCursor(cursor)); } while (cursor.moveToNext()); @@ -182,7 +182,7 @@ public abstract class BookmarkBaseGateway { Cursor cursor = queryBookmarks(null, "label"); ArrayList bookmarks = new ArrayList(cursor.getCount()); - if (cursor.moveToFirst()) { + if (cursor.moveToFirst() && (cursor.getCount() > 0)) { do { bookmarks.add(getBookmarkFromCursor(cursor)); } while (cursor.moveToNext()); diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java index 35f3402cb..4e7ecb952 100644 --- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java +++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java @@ -77,7 +77,7 @@ public class ManualBookmarkGateway extends BookmarkBaseGateway { Cursor cursor = queryBookmarks("label = '" + pattern + "' OR hostname = '" + pattern + "'", "label"); BookmarkBase bookmark = null; - if (cursor.moveToFirst()) + if (cursor.moveToFirst() && (cursor.getCount() > 0)) bookmark = getBookmarkFromCursor(cursor); cursor.close(); @@ -88,7 +88,7 @@ public class ManualBookmarkGateway extends BookmarkBaseGateway { Cursor cursor = queryBookmarks("label LIKE '%" + pattern + "%' OR hostname LIKE '%" + pattern + "%'", "label"); ArrayList bookmarks = new ArrayList(cursor.getCount()); - if (cursor.moveToFirst()) { + if (cursor.moveToFirst() && (cursor.getCount() > 0)) { do { bookmarks.add(getBookmarkFromCursor(cursor)); } while (cursor.moveToNext());