From ab3f65a15e1b6fe5bdf488e6e879899e283ccc43 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 30 Nov 2012 15:29:34 +0100 Subject: Address couple issues found by a Coverity scan --- calendar/gui/print.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'calendar/gui/print.c') diff --git a/calendar/gui/print.c b/calendar/gui/print.c index 85a293e6fa..b4e6ff2133 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -672,32 +672,33 @@ format_date (struct tm *tm, gchar *buffer, gint bufflen) { - gchar fmt[64]; + GString *fmt = g_string_new (""); - fmt[0] = 0; if (flags & DATE_DAYNAME) { - strcat (fmt, "%A"); + g_string_append (fmt, "%A"); } if (flags & DATE_DAY) { if (flags & DATE_DAYNAME) - strcat (fmt, " "); - strcat (fmt, gettext (days[tm->tm_mday - 1])); + g_string_append (fmt, " "); + g_string_append (fmt, gettext (days[tm->tm_mday - 1])); } if (flags & DATE_MONTH) { if (flags & (DATE_DAY | DATE_DAYNAME)) - strcat (fmt, " "); - strcat (fmt, "%B"); + g_string_append (fmt, " "); + g_string_append (fmt, "%B"); if ((flags & (DATE_DAY | DATE_YEAR)) == (DATE_DAY | DATE_YEAR)) - strcat (fmt, ","); + g_string_append (fmt, ","); } if (flags & DATE_YEAR) { if (flags & (DATE_DAY | DATE_DAYNAME | DATE_MONTH)) - strcat (fmt, " "); - strcat (fmt, "%Y"); + g_string_append (fmt, " "); + g_string_append (fmt, "%Y"); } - e_utf8_strftime (buffer, bufflen, fmt, tm); + e_utf8_strftime (buffer, bufflen, fmt->str, tm); buffer[bufflen - 1] = '\0'; + g_string_free (fmt, TRUE); + return buffer; } -- cgit v1.2.3