]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
change copy tm values and free it by xml
authorBastian Dehn <hhaalo@arcor.de>
Wed, 11 Feb 2026 18:46:55 +0000 (19:46 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Wed, 11 Feb 2026 18:46:55 +0000 (19:46 +0100)
src/xml.c

index 91c858e08e761b5ba329e58344258b5c15868228..1ef5a96b1ae3931efd7d8ff1f91c3f3ae09a1c21 100644 (file)
--- 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;
 }