From 3d9a616632dbb85df656d89b73c6f41d444d06d5 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 14 Aug 2018 10:54:49 +0200 Subject: [PATCH] flatpakref: Fix leak of gpg key string Closes: #1966 Approved by: alexlarsson --- common/flatpak-dir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 70841e3d..9f30efa7 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -10690,7 +10690,7 @@ parse_ref_file (GKeyFile *keyfile, g_autoptr(GBytes) gpg_data = NULL; gboolean is_runtime = FALSE; g_autofree char *collection_id = NULL; - char *str; + g_autofree char *str = NULL; *name_out = NULL; *branch_out = NULL; @@ -10732,7 +10732,7 @@ parse_ref_file (GKeyFile *keyfile, FLATPAK_REF_GPGKEY_KEY, NULL); if (str != NULL) { - guchar *decoded; + g_autofree guchar *decoded = NULL; gsize decoded_len; str = g_strstrip (str); @@ -10740,7 +10740,7 @@ parse_ref_file (GKeyFile *keyfile, if (decoded_len < 10) /* Check some minimal size so we don't get crap */ return flatpak_fail (error, "Invalid file format, gpg key invalid"); - gpg_data = g_bytes_new_take (decoded, decoded_len); + gpg_data = g_bytes_new_take (g_steal_pointer (&decoded), decoded_len); } collection_id = g_key_file_get_string (keyfile, FLATPAK_REF_GROUP,