From ee65ce2931212a5161b3fac17a0d6031ee606559 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 26 Oct 2012 10:26:42 -0700 Subject: [PATCH] Fixed potential null pointer when scheduling calendar events --- .../com/todoroo/astrid/gcal/CalendarAlarmScheduler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/gcal/CalendarAlarmScheduler.java b/astrid/plugin-src/com/todoroo/astrid/gcal/CalendarAlarmScheduler.java index fd3f8c1f8..86eb3fe3e 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gcal/CalendarAlarmScheduler.java +++ b/astrid/plugin-src/com/todoroo/astrid/gcal/CalendarAlarmScheduler.java @@ -39,7 +39,7 @@ public class CalendarAlarmScheduler { new String[] { Long.toString(now + DateUtilities.ONE_MINUTE * 15), Long.toString(now + DateUtilities.ONE_DAY) }, null); try { - if (events.getCount() > 0) { + if (events != null && events.getCount() > 0) { int idIndex = events.getColumnIndex(Calendars.ID_COLUMN_NAME); int dtstartIndex = events.getColumnIndexOrThrow(Calendars.EVENTS_DTSTART_COL); @@ -73,7 +73,8 @@ public class CalendarAlarmScheduler { am.cancel(pendingReschedule); am.set(AlarmManager.RTC, DateUtilities.now() + DateUtilities.ONE_HOUR * 12, pendingReschedule); } finally { - events.close(); + if (events != null) + events.close(); } }