From: Bastian Dehn Date: Wed, 11 Feb 2026 18:46:55 +0000 (+0100) Subject: change copy tm values and free it by xml X-Git-Tag: 1.3.11^2~2 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=728f6315fd61f976ea9a4150417686482edd0508;p=feierabend.git change copy tm values and free it by xml --- diff --git a/src/xml.c b/src/xml.c index 91c858e..1ef5a96 100644 --- a/src/xml.c +++ b/src/xml.c @@ -150,9 +150,8 @@ void writeEntryNode(xmlTextWriterPtr xmlWriter, xmlElemName = NULL; time(&fabend->now); - free(fabend->now_tm); - fabend->now_tm = NULL; - fabend->now_tm = gmtime(&fabend->now); + const struct tm* tmp_now = gmtime(&fabend->now); + memcpy(fabend->now_tm, tmp_now, sizeof(struct tm)); if (date != NULL) { fabend->now_tm->tm_year = get_year_from_str(date) - 1900; fabend->now_tm->tm_mon = get_month_from_str(date) - 1; @@ -187,9 +186,8 @@ void writeEntryNode(xmlTextWriterPtr xmlWriter, xmlElemContent = NULL; time(&fabend->begin); - free(fabend->begin_tm); - fabend->begin_tm = NULL; - fabend->begin_tm = gmtime(&fabend->begin); + const struct tm* tmp_begin = gmtime(&fabend->begin); + memcpy(fabend->begin_tm, tmp_begin, sizeof(struct tm)); if (date != NULL) { fabend->begin_tm->tm_year = get_year_from_str(date) - 1900; fabend->begin_tm->tm_mon = get_month_from_str(date) - 1; @@ -211,9 +209,8 @@ void writeEntryNode(xmlTextWriterPtr xmlWriter, xmlElemContent = NULL; fabend->worktime = get_eight_hour_end_worktime(fabend->begin); - free(fabend->work_end_tm); - fabend->work_end_tm = NULL; - fabend->work_end_tm = gmtime(&fabend->worktime); + const struct tm* tmp_work_end = gmtime(&fabend->worktime); + memcpy(fabend->work_end_tm, tmp_work_end, sizeof(struct tm)); if (date != NULL) { fabend->work_end_tm->tm_year = get_year_from_str(date) - 1900; fabend->work_end_tm->tm_mon = get_month_from_str(date) - 1; @@ -297,8 +294,7 @@ void writeEntryNode(xmlTextWriterPtr xmlWriter, xmlElemContent = NULL; free(xmlElemName); xmlElemName = NULL; - free(fabend->max_work_end_tm); - fabend->max_work_end_tm = NULL; + feierabend_free(fabend); free(fabend); fabend = NULL; }