From 51222781f21f055f26b0a1a7afadfb35b9acf768 Mon Sep 17 00:00:00 2001 From: Yepang Liu Date: Sun, 9 Oct 2016 11:47:10 +0800 Subject: [PATCH] fix database cursor leak in GpxImportHelper.java I moved the database cursor closing code outside the if block to fix the potential leak of empty database cursor (when moveToFirst() returns false). --- OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java index 12b65ade96..f45d851b43 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java @@ -81,10 +81,12 @@ public class GpxImportHelper { final Cursor returnCursor = application.getContentResolver().query(contentUri, null, null, null, null); if (returnCursor != null && returnCursor.moveToFirst()) { name = returnCursor.getString(returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); - returnCursor.close(); } else { name = null; } + if (returnCursor != null && !returnCursor.isClosed()) { + returnCursor.close(); + } return name; }