Fix memory leak in update_duration()

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen 2018-06-01 07:43:34 +02:00 committed by Lukas Fleischer
parent b6cdc29255
commit 0543df5f31

View File

@ -161,10 +161,13 @@ static void update_duration(long *start, long *dur)
int ret, early = 0; int ret, early = 0;
status_mesg(msg_time, ""); status_mesg(msg_time, "");
ret = updatestring(win[STA].p, &timestr, 0, 1); ret = updatestring(win[STA].p, &timestr, 0, 1);
if (ret == GETSTRING_ESC) if (ret == GETSTRING_ESC) {
mem_free(timestr);
return; return;
}
if (*(timestr + strlen(timestr) - 1) == '?') { if (*(timestr + strlen(timestr) - 1) == '?') {
asprintf(&outstr, "%s %s", DATEFMT(conf.input_datefmt), "%H:%M"); asprintf(&outstr, "%s %s", DATEFMT(conf.input_datefmt), "%H:%M");
mem_free(timestr);
timestr = date_sec2date_str(end, outstr); timestr = date_sec2date_str(end, outstr);
asprintf(&outstr, msg_help_1, DATEFMT_DESC(conf.input_datefmt)); asprintf(&outstr, msg_help_1, DATEFMT_DESC(conf.input_datefmt));
status_mesg(outstr, msg_help_2); status_mesg(outstr, msg_help_2);