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

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