From 12de4748082f542f32bbf9c31cf44b9c1ee8279a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 16 May 2018 11:27:25 +0100 Subject: [PATCH] gtimezone: Fix two minor leaks in zone_info_unix() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • A leak of filename on an error path • A leak of resolved_identifier if no out_identifier return location was provided The latter was spotted by Peter Bloomfield (https://gitlab.gnome.org/GNOME/glib/commit/8945227743a26a4fe6966baaf082dd6516e8a03c#note_111254). Thanks! Signed-off-by: Philip Withnall Reviewed-by: nobody --- glib/gtimezone.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/glib/gtimezone.c b/glib/gtimezone.c index 896c117bc..72a4916ad 100644 --- a/glib/gtimezone.c +++ b/glib/gtimezone.c @@ -457,9 +457,8 @@ zone_info_unix (const gchar *identifier, else { /* Error */ - if (out_identifier != NULL) - *out_identifier = NULL; - return NULL; + g_assert (resolved_identifier == NULL); + goto out; } } else @@ -494,12 +493,16 @@ zone_info_unix (const gchar *identifier, g_mapped_file_ref (file)); g_mapped_file_unref (file); } - g_free (filename); g_assert (resolved_identifier != NULL); + +out: if (out_identifier != NULL) *out_identifier = g_steal_pointer (&resolved_identifier); + g_free (resolved_identifier); + g_free (filename); + return zoneinfo; }