diff --git a/glib/gdatetime.c b/glib/gdatetime.c index 1755257be..c2180e443 100644 --- a/glib/gdatetime.c +++ b/glib/gdatetime.c @@ -1383,15 +1383,15 @@ parse_iso8601_timezone (const gchar *text, gsize length, gssize *tz_offset) return NULL; *tz_offset = i; - tz = g_time_zone_new (text + i); + tz = g_time_zone_new_identifier (text + i); /* Double-check that the GTimeZone matches our interpretation of the timezone. * This can fail because our interpretation is less strict than (for example) * parse_time() in gtimezone.c, which restricts the range of the parsed * integers. */ - if (g_time_zone_get_offset (tz, 0) != offset_sign * (offset_hours * 3600 + offset_minutes * 60)) + if (tz == NULL || g_time_zone_get_offset (tz, 0) != offset_sign * (offset_hours * 3600 + offset_minutes * 60)) { - g_time_zone_unref (tz); + g_clear_pointer (&tz, g_time_zone_unref); return NULL; }