Skip to content

Commit

Permalink
Add error handling around for loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
toolstack authored and Gitsaibot committed Jan 18, 2024
1 parent 498b098 commit e97365e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions app/src/main/java/com/android/calendar/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,22 @@ static int checkRRuleEventDate( String rrule, long startTime, int endDay) {
return endDay;
}

// Create the recurrence set for the rule, we're only going to look at the first one
// as it should match the firstInstance if this is a valid event from Android.
for (DateTime instance:newRecurrenceSet) {
if (!instance.equals(firstInstance)) {
// If this isn't a valid event, return 0 so it gets removed from the event list.
return 0;
} else {
// If this is a valid event, return the endDay that we were passed in with.
return endDay;
// Wrap the for loop in a try/catch to ensure we don't run into an invalid
// rule set that lib-recur can't parse.
try {
// Create the recurrence set for the rule, we're only going to look at the first one
// as it should match the firstInstance if this is a valid event from Android.
for (DateTime instance:newRecurrenceSet) {
if (!instance.equals(firstInstance)) {
// If this isn't a valid event, return 0 so it gets removed from the event list.
return 0;
} else {
// If this is a valid event, return the endDay that we were passed in with.
return endDay;
}
}
} catch (Exception e) {
return endDay;
}

// We should never get here, but add a return just in case.
Expand Down

0 comments on commit e97365e

Please sign in to comment.