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

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