Blame SOURCES/0002-tree-Avoid-use-of-memory-after-it-s-freed.patch

f40e4d
From d1baaf2946513be06f97ab66e7845e14073add3d Mon Sep 17 00:00:00 2001
f40e4d
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
f40e4d
Date: Tue, 21 May 2019 13:29:18 +0200
f40e4d
Subject: [PATCH 2/3] tree: Avoid use of memory after it's freed
f40e4d
MIME-Version: 1.0
f40e4d
Content-Type: text/plain; charset=UTF-8
f40e4d
Content-Transfer-Encoding: 8bit
f40e4d
f40e4d
We've been passing data->location as the @url argument of
f40e4d
osinfo_tree_create_from_location_async_helper(), freeing it and trying
f40e4d
to g_strdup() it as the new content of data->location.
f40e4d
f40e4d
In order to avoid doing so, let's set the data->location only once, in
f40e4d
the first caller of osinfo_tree_create_from_location_async_helper(), as
f40e4d
its content is always going to be the same doesn't matter the treeinfo
f40e4d
format to be used with.
f40e4d
f40e4d
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
f40e4d
Reviewed-by: Cole Robinson <crobinso@redhat.com>
f40e4d
(cherry picked from commit d7bc838a96acf5f058e13d2b49157b4ba396cd87)
f40e4d
---
f40e4d
 osinfo/osinfo_tree.c | 5 ++---
f40e4d
 1 file changed, 2 insertions(+), 3 deletions(-)
f40e4d
f40e4d
diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c
f40e4d
index 88a2d6e..ab498f0 100644
f40e4d
--- a/osinfo/osinfo_tree.c
f40e4d
+++ b/osinfo/osinfo_tree.c
f40e4d
@@ -702,9 +702,6 @@ osinfo_tree_create_from_location_async_helper(const gchar *url,
f40e4d
     g_clear_object(&data->file);
f40e4d
     data->file = g_file_new_for_uri(location);
f40e4d
 
f40e4d
-    g_free(data->location);
f40e4d
-    data->location = g_strdup(url);
f40e4d
-
f40e4d
     g_free(data->treeinfo);
f40e4d
     data->treeinfo = g_strdup(treeinfo);
f40e4d
 
f40e4d
@@ -740,6 +737,8 @@ void osinfo_tree_create_from_location_async(const gchar *location,
f40e4d
                            user_data);
f40e4d
     g_task_set_priority(data->res, priority);
f40e4d
 
f40e4d
+    data->location = g_strdup(location);
f40e4d
+
f40e4d
     osinfo_tree_create_from_location_async_helper(location,
f40e4d
                                                   ".treeinfo",
f40e4d
                                                   cancellable,
f40e4d
-- 
f40e4d
2.21.0
f40e4d