Add missing string initialization

When introducing the fmt_day_heading() function in commit d56cc7a (Make
heading in appointments panel configurable, 2017-08-19), we forgot to
initialize the dynamic string. This resulted in calling mem_free() with
a garbage pointer, potentially resulting in a segmentation fault. Fix
this by calling string_init() before using the string.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen 2017-09-04 09:17:14 +02:00 committed by Lukas Fleischer
parent 2e584f03e6
commit 3095bf4214

View File

@ -915,6 +915,7 @@ static char *fmt_day_heading(time_t date)
struct string s;
localtime_r(&date, &tm);
string_init(&s);
string_printf(&s, "%s ", ui_calendar_get_pom(date));
string_catftime(&s, conf.day_heading, &tm);
return string_buf(&s);