Skip to content

Commit

Permalink
Merge pull request #5197 from rsto/cyr-1479-fix-memory-leak-duplicate…
Browse files Browse the repository at this point in the history
…-recur-by-ref

ical_support.c: bump refcount of rrules in multirrule iterator
  • Loading branch information
rsto authored Jan 9, 2025
2 parents f85fdf0 + 75750c8 commit 7fb63d6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions imap/ical_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,11 @@ static void multirrule_iterator_add(struct multirrule_iterator *iter,
entry->icaliter = icaliter;
entry->next = icalrecur_iterator_next(entry->icaliter);
entry->recur = recur;
#ifdef HAVE_RECUR_BY_REF
icalrecurrencetype_ref(recur);
#else /* !HAVE_RECUR_BY_REF */
entry->recur->rscale = xstrdupnull(recur->rscale);
#endif /* HAVE_RECUR_BY_REF */
}

static icaltimetype multirrule_iterator_next(struct multirrule_iterator *iter)
Expand Down Expand Up @@ -574,9 +578,14 @@ multirrule_iterator_for_range(icalcomponent *comp,
if (!span_compare_range(&recur_span, &range_span)) {
multirrule_iterator_add(&iter, recur, dtstart, range.start);
}

#ifdef HAVE_RECUR_BY_REF
icalrecurrencetype_unref(recur);
#else /* !HAVE_RECUR_BY_REF */
else {
icalrecurrencetype_unref(recur);
}
#endif
}

return iter;
Expand Down

0 comments on commit 7fb63d6

Please sign in to comment.