summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2015-04-10 16:18:38 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2015-04-10 16:18:38 +0200
commitd354a4a05d1f280a3ab4e011b7f954c409a3229e (patch)
tree90c2e75ae90b5c9134f67e0261a62e8c0f18cead
parentf07ef77437d5a5dd3d190e3e95b38c218638a890 (diff)
downloadcalcurse-d354a4a05d1f280a3ab4e011b7f954c409a3229e.tar.gz
calcurse-d354a4a05d1f280a3ab4e011b7f954c409a3229e.zip
Fix range checks in day_chk_busy_slices()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/day.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/day.c b/src/day.c
index 219d8a6..75719a6 100644
--- a/src/day.c
+++ b/src/day.c
@@ -567,16 +567,19 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
recur_apoint_inday, i) {
struct recur_apoint *rapt = LLIST_TS_GET_DATA(i);
time_t occurrence;
- long start;
- long end = get_item_time(rapt->start + rapt->dur);
+ long start, end;
if (!recur_apoint_find_occurrence(rapt, t, &occurrence))
continue;
- start = get_item_time(occurrence);
- if (rapt->start < t)
+ if (occurrence >= t)
+ start = get_item_time(occurrence);
+ else
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;
if (!fill_slices