From 06a4449afae29d4dd0e5d49249674511bb1f4489 Mon Sep 17 00:00:00 2001
From: Lars Henriksen <LarsHenriksen@get2net.dk>
Date: Thu, 7 Mar 2019 20:38:08 +0100
Subject: Fix initialization of the day_items vector

This patch fixes all failings tests, but one, in PR #193.

Until now the missing initialization of day_items_nb has caused no
problems, because the variable was assigned to (=) before being used. In
the Multiple days implementation it is repeatedly increased (+=) in a
loop without being initialized first. Indeed, this may considered an
easily fixed bug. But the initialization really belongs in
day_init_vector() so that the call day_item_count(0) returns 0 if done
right after the call day_init_vector(). The bug only shows up in command
line mode because day_items_nb is not used in interactive mode.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
---
 src/day.c | 1 +
 1 file changed, 1 insertion(+)

(limited to 'src')

diff --git a/src/day.c b/src/day.c
index 50d6639..96b863a 100644
--- a/src/day.c
+++ b/src/day.c
@@ -52,6 +52,7 @@ static void day_free(struct day_item *day)
 
 static void day_init_vector(void)
 {
+	day_items_nb = 0;
 	VECTOR_INIT(&day_items, 16);
 }
 
-- 
cgit v1.2.3-70-g09d2