Fix range checks in day_chk_busy_slices()

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2015-04-10 16:18:38 +02:00
parent f07ef77437
commit d354a4a05d

View File

@ -567,16 +567,19 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
recur_apoint_inday, i) { recur_apoint_inday, i) {
struct recur_apoint *rapt = LLIST_TS_GET_DATA(i); struct recur_apoint *rapt = LLIST_TS_GET_DATA(i);
time_t occurrence; time_t occurrence;
long start; long start, end;
long end = get_item_time(rapt->start + rapt->dur);
if (!recur_apoint_find_occurrence(rapt, t, &occurrence)) if (!recur_apoint_find_occurrence(rapt, t, &occurrence))
continue; continue;
start = get_item_time(occurrence);
if (rapt->start < t) if (occurrence >= t)
start = get_item_time(occurrence);
else
start = 0; start = 0;
if (rapt->start + rapt->dur >= t + DAYINSEC)
if (occurrence + rapt->dur < t + DAYINSEC)
end = get_item_time(occurrence + rapt->dur);
else
end = DAYINSEC - 1; end = DAYINSEC - 1;
if (!fill_slices if (!fill_slices