From 7273f3d88e0e7be7cc06313835c5f50827fc4f91 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 25 May 2012 12:33:02 +0200 Subject: [PATCH] Calendar: fix some uninitialized value conditions pointed out by clang static analyzer --- citadel/modules/calendar/serv_calendar.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/citadel/modules/calendar/serv_calendar.c b/citadel/modules/calendar/serv_calendar.c index 84fb9683c..2c9419692 100644 --- a/citadel/modules/calendar/serv_calendar.c +++ b/citadel/modules/calendar/serv_calendar.c @@ -986,6 +986,9 @@ void ical_conflicts_phase5(struct icaltimetype t1start, } dur = icaltime_subtract(t2end, t2start); } + else { + memset (&dur, 0, sizeof(struct icaldurationtype)); + } rrule = ical_ctdl_get_subprop(existing_event, ICAL_RRULE_PROPERTY); if (rrule) { @@ -1056,13 +1059,16 @@ void ical_conflicts_phase4(icalcomponent *proposed_event, int num_recur = 0; /* initialization */ - strcpy(compare_uid, ""); + *compare_uid = '\0'; /* proposed event stuff */ p = ical_ctdl_get_subprop(proposed_event, ICAL_DTSTART_PROPERTY); - if (p == NULL) return; - if (p != NULL) t1start = icalproperty_get_dtstart(p); + if (p == NULL) + return; + else + t1start = icalproperty_get_dtstart(p); + if (icaltime_is_utc(t1start)) { t1start.zone = icaltimezone_get_utc_timezone(); } @@ -1097,6 +1103,9 @@ void ical_conflicts_phase4(icalcomponent *proposed_event, dur = icaltime_subtract(t1end, t1start); } + else { + memset (&dur, 0, sizeof(struct icaldurationtype)); + } rrule = ical_ctdl_get_subprop(proposed_event, ICAL_RRULE_PROPERTY); if (rrule) { @@ -1244,8 +1253,8 @@ void ical_add_to_freebusy(icalcomponent *fb, icalcomponent *top_level_cal) { icalproperty *p; icalvalue *v; struct icalperiodtype this_event_period = icalperiodtype_null_period(); - icaltimetype dtstart = icaltime_null_time(); - icaltimetype dtend = icaltime_null_time(); + icaltimetype dtstart; + icaltimetype dtend; /* recur variables */ icalproperty *rrule = NULL; @@ -1298,6 +1307,9 @@ void ical_add_to_freebusy(icalcomponent *fb, icalcomponent *top_level_cal) { if (!icaltime_is_null_time(dtend)) { dur = icaltime_subtract(dtend, dtstart); } + else { + memset (&dur, 0, sizeof(struct icaldurationtype)); + } /* Is a recurrence specified? If so, get ready to process it... */ rrule = ical_ctdl_get_subprop(cal, ICAL_RRULE_PROPERTY); -- 2.30.2