gdatetime: Fix a spurious gcc warning

It’s possible to get a -Wmaybe-uninitialized warning out of this code
with some GCC versions. Rework the code to avoid needing the conditional
free.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=728108
This commit is contained in:
Philip Withnall 2018-04-12 13:19:21 +01:00
parent 68f6d39895
commit a80117c371

View File

@ -3197,6 +3197,7 @@ g_date_time_format_locale (GDateTime *datetime,
break;
case 'Z':
tz = g_date_time_get_timezone_abbreviation (datetime);
tmp = NULL;
tmp_len = strlen (tz);
if (!locale_is_utf8)
{
@ -3205,8 +3206,7 @@ g_date_time_format_locale (GDateTime *datetime,
return FALSE;
}
g_string_append_len (outstr, tz, tmp_len);
if (!locale_is_utf8)
g_free (tmp);
g_free (tmp);
break;
case '%':
g_string_append_c (outstr, '%');